session: restore sgr mouse encoding in the attach snapshot
376 unmodified linesExpand all377378379380381381382383384385386387388389390304 unmodified linesExpand all376 unmodified linesExpand all o.idleTimer = nil } o.viewers[vc] = struct{}{} o.applySizeLocked() return vc, o.addon.Serialize(nil) return vc, append(o.addon.Serialize(nil), mouseEncodings[o.vt.DecPrivateModes().MouseEncoding]...)}
// the serializer restores mouse tracking but not its encoding, so a new viewer would report in X10var mouseEncodings = map[string]string{"SGR": "\x1b[?1006h", "SGR_PIXELS": "\x1b[?1016h"}
func (o *Owner) removeViewer(vc *viewerClient) { o.mu.Lock() defer o.mu.Unlock() delete(o.viewers, vc)304 unmodified linesExpand all74 unmodified lines7576777879808182838485868788899091929394959697989910085 unmodified lines74 unmodified lines t.Fatal("killing a dead session succeeded") }}
func TestSnapshotKeepsMouseEncoding(t *testing.T) { t.Setenv("XDG_RUNTIME_DIR", shortTempDir(t)) sp := startOwner(t, "sh") v := attach(t, sp) defer v.Close() _ = protocol.WriteFrame(v, protocol.TypeInput, []byte("printf '\\033[?1002h\\033[?1006h'; echo done\n")) expectFrame(t, v, protocol.TypeOutput, "done") c, err := net.Dial("unix", sp) if err != nil { t.Fatal(err) } defer c.Close() _ = protocol.WriteFrame(c, protocol.TypeAttach, protocol.EncodeSize(80, 24)) if _, snap, err := protocol.ReadFrame(c); err != nil || !strings.Contains(string(snap), "\x1b[?1006h") { t.Fatalf("snapshot lost sgr mouse: %v %q", err, snap) }}
func TestQueryFilter(t *testing.T) { var f queryFilter for _, tc := range []struct{ in, want string }{ {"\x1b]10", ""}, {";?\x1b\\", ""},85 unmodified lines