detached f053137

fix(screen): keep REP eligibility across empty writes after a lone ESC

commit
f05313741739bc8875e186e4ed01788fec63d6a0
author
brice · · 2026-10-15 02:39 UTC
parent
6209370
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +22 -7
M screen.go +5 -2
@@ -184,8 +184,11 @@ func (s *Screen) Write(data []byte) {
184184 if len(s.escapeBuf) == 0 {
185185 s.trimEscapeBuffers()
186186 } else if isKittyEscapeContinuation(s.escapeBuf, data) {
187- // A Kitty APC sits between any earlier graphic and what follows.
188- s.lastPrinted = 0
187+ // A Kitty APC sits between any earlier graphic and what follows. An
188+ // empty write has not identified the buffered escape yet.
189+ if len(data) > 0 {
190+ s.lastPrinted = 0
191+ }
189192 prefix := s.escapeBuf
190193 s.escapeBuf = nil
191194 data = s.continueKittyEscape(prefix, data)
@@ -184,8 +184,11 @@ func (s *Screen) Write(data []byte) {
184 if len(s.escapeBuf) == 0 {184 if len(s.escapeBuf) == 0 {
185 s.trimEscapeBuffers()185 s.trimEscapeBuffers()
186 } else if isKittyEscapeContinuation(s.escapeBuf, data) {186 } else if isKittyEscapeContinuation(s.escapeBuf, data) {
187- // A Kitty APC sits between any earlier graphic and what follows.187+ // A Kitty APC sits between any earlier graphic and what follows. An
188- s.lastPrinted = 0188+ // empty write has not identified the buffered escape yet.
189+ if len(data) > 0 {
190+ s.lastPrinted = 0
191+ }
189 prefix := s.escapeBuf192 prefix := s.escapeBuf
190 s.escapeBuf = nil193 s.escapeBuf = nil
191 data = s.continueKittyEscape(prefix, data)194 data = s.continueKittyEscape(prefix, data)
M screen_charset_test.go +17 -5
@@ -60,11 +60,23 @@ func TestSoftResetCursorAppearance(t *testing.T) {
6060 }
6161
6262 func TestRepeatSplitAcrossWrites(t *testing.T) {
63- s := NewScreen(10, 1)
64- s.Write([]byte("a\x1b["))
65- s.Write([]byte("2b"))
66- if got := strings.TrimRight(lineText(s, 0), " "); got != "aaa" {
67- t.Fatalf("line = %q, want %q", got, "aaa")
63+ tests := []struct {
64+ name string
65+ writes []string
66+ }{
67+ {name: "split inside CSI", writes: []string{"a\x1b[", "2b"}},
68+ {name: "empty write after lone ESC", writes: []string{"a\x1b", "", "[2b"}},
69+ }
70+ for _, tt := range tests {
71+ t.Run(tt.name, func(t *testing.T) {
72+ s := NewScreen(10, 1)
73+ for _, w := range tt.writes {
74+ s.Write([]byte(w))
75+ }
76+ if got := strings.TrimRight(lineText(s, 0), " "); got != "aaa" {
77+ t.Fatalf("line = %q, want %q", got, "aaa")
78+ }
79+ })
6880 }
6981 }
7082
@@ -60,11 +60,23 @@ func TestSoftResetCursorAppearance(t *testing.T) {
60 }60 }
61 61
62 func TestRepeatSplitAcrossWrites(t *testing.T) {62 func TestRepeatSplitAcrossWrites(t *testing.T) {
63- s := NewScreen(10, 1)63+ tests := []struct {
64- s.Write([]byte("a\x1b["))64+ name string
65- s.Write([]byte("2b"))65+ writes []string
66- if got := strings.TrimRight(lineText(s, 0), " "); got != "aaa" {66+ }{
67- t.Fatalf("line = %q, want %q", got, "aaa")67+ {name: "split inside CSI", writes: []string{"a\x1b[", "2b"}},
68+ {name: "empty write after lone ESC", writes: []string{"a\x1b", "", "[2b"}},
69+ }
70+ for _, tt := range tests {
71+ t.Run(tt.name, func(t *testing.T) {
72+ s := NewScreen(10, 1)
73+ for _, w := range tt.writes {
74+ s.Write([]byte(w))
75+ }
76+ if got := strings.TrimRight(lineText(s, 0), " "); got != "aaa" {
77+ t.Fatalf("line = %q, want %q", got, "aaa")
78+ }
79+ })
68 }80 }
69 }81 }
70 82

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 13

↑↓ moveenter openesc close