fix(copy): keep off-frame selected cursors covered
- commit
- b6b72659a082d516643a1993d4e91375305005e4
- author
- brice · · 2026-10-05 07:32 UTC
- parent
- cb18da6
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +11 -4
M internal/usecase/copy/content_render_test.go +6 -3
| @@ -78,10 +78,13 @@ func TestRenderRowsSelectionAfterHistoryResize(t *testing.T) { | |||
| 78 | 78 | m.navigator.Pos = Pos{0, 0} | |
| 79 | 79 | m.ViewportTop = 0 | |
| 80 | 80 | m.selection = Selection{Anchor: Pos{0, 0}, Active: Pos{1, 0}, Granularity: Character, Enabled: true} | |
| 81 | - | f := m.Render(vt.DefaultStyle(), vt.Style{HasBackgroundRGB: true}) | |
| 82 | 81 | require.Equal(t, "abc xyz\nq", m.SelectedText()) | |
| 83 | - | for x := 0; x < 8; x++ { | |
| 84 | - | require.True(t, f.At(x, 0).Style.Inverse, "visible content column %d", x) | |
| 82 | + | for _, col := range []int{0, 10} { | |
| 83 | + | m.navigator.Pos = Pos{0, col} | |
| 84 | + | f := m.Render(vt.DefaultStyle(), vt.Style{HasBackgroundRGB: true}) | |
| 85 | + | for x := 0; x < 8; x++ { | |
| 86 | + | require.True(t, f.At(x, 0).Style.Inverse, "cursor %d, visible content column %d", col, x) | |
| 87 | + | } | |
| 85 | 88 | } | |
| 86 | 89 | } | |
| 87 | 90 | ||
| @@ -78,10 +78,13 @@ func TestRenderRowsSelectionAfterHistoryResize(t *testing.T) { | |||||
| 78 | m.navigator.Pos = Pos{0, 0} | 78 | m.navigator.Pos = Pos{0, 0} | ||
| 79 | m.ViewportTop = 0 | 79 | m.ViewportTop = 0 | ||
| 80 | m.selection = Selection{Anchor: Pos{0, 0}, Active: Pos{1, 0}, Granularity: Character, Enabled: true} | 80 | m.selection = Selection{Anchor: Pos{0, 0}, Active: Pos{1, 0}, Granularity: Character, Enabled: true} | ||
| 81 | - | f := m.Render(vt.DefaultStyle(), vt.Style{HasBackgroundRGB: true}) | |||
| 82 | require.Equal(t, "abc xyz\nq", m.SelectedText()) | 81 | require.Equal(t, "abc xyz\nq", m.SelectedText()) | ||
| 83 | - | for x := 0; x < 8; x++ { | 82 | + | for _, col := range []int{0, 10} { |
| 84 | - | require.True(t, f.At(x, 0).Style.Inverse, "visible content column %d", x) | 83 | + | m.navigator.Pos = Pos{0, col} |
| 84 | + | f := m.Render(vt.DefaultStyle(), vt.Style{HasBackgroundRGB: true}) | |||
| 85 | + | for x := 0; x < 8; x++ { | |||
| 86 | + | require.True(t, f.At(x, 0).Style.Inverse, "cursor %d, visible content column %d", col, x) | |||
| 87 | + | } | |||
| 85 | } | 88 | } | ||
| 86 | } | 89 | } | ||
| 87 | 90 | ||||
M internal/usecase/copy/mode.go +5 -1
| @@ -609,7 +609,11 @@ func (m *Mode) RenderRowsRange(start, end int, paint func(int, []renderer.Cell), | |||
| 609 | 609 | if n < d.RowWidth(src) { | |
| 610 | 610 | limit = d.contentEnd(src) | |
| 611 | 611 | } | |
| 612 | - | if r, ok := selectionBounds.rangeForCells(src, row, limit); ok { | |
| 612 | + | r, ok := selectionBounds.rangeForCells(src, row, limit) | |
| 613 | + | if n < d.RowWidth(src) { | |
| 614 | + | r, ok = selectionBounds.rangeForRow(d, src) | |
| 615 | + | } | |
| 616 | + | if ok { | |
| 613 | 617 | for x := max(r.Start, 0); x <= min(r.End, len(row)-1); x++ { | |
| 614 | 618 | toggleInverse(&row[x].Style) | |
| 615 | 619 | } | |
| @@ -609,7 +609,11 @@ func (m *Mode) RenderRowsRange(start, end int, paint func(int, []renderer.Cell), | |||||
| 609 | if n < d.RowWidth(src) { | 609 | if n < d.RowWidth(src) { | ||
| 610 | limit = d.contentEnd(src) | 610 | limit = d.contentEnd(src) | ||
| 611 | } | 611 | } | ||
| 612 | - | if r, ok := selectionBounds.rangeForCells(src, row, limit); ok { | 612 | + | r, ok := selectionBounds.rangeForCells(src, row, limit) |
| 613 | + | if n < d.RowWidth(src) { | |||
| 614 | + | r, ok = selectionBounds.rangeForRow(d, src) | |||
| 615 | + | } | |||
| 616 | + | if ok { | |||
| 613 | for x := max(r.Start, 0); x <= min(r.End, len(row)-1); x++ { | 617 | for x := max(r.Start, 0); x <= min(r.End, len(row)-1); x++ { | ||
| 614 | toggleInverse(&row[x].Style) | 618 | toggleInverse(&row[x].Style) | ||
| 615 | } | 619 | } | ||