perf(copy): reuse full history rows for selection bounds
- commit
- 1b6fda79f0bbfff873328267dc6c9c8fdc77d334
- author
- brice · · 2026-10-05 08:11 UTC
- parent
- b6b7265
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +8 -8
M internal/usecase/copy/mode.go +8 -8
| @@ -605,19 +605,19 @@ func (m *Mode) RenderRowsRange(start, end int, paint func(int, []renderer.Cell), | |||
| 605 | 605 | cursorCovered := false | |
| 606 | 606 | if hasSelectionBounds { | |
| 607 | 607 | bound := d.snapshot.Bound(src) | |
| 608 | - | limit := contentEndOf(row[:n], bound) | |
| 609 | - | if n < d.RowWidth(src) { | |
| 610 | - | limit = d.contentEnd(src) | |
| 611 | - | } | |
| 612 | - | r, ok := selectionBounds.rangeForCells(src, row, limit) | |
| 613 | - | if n < d.RowWidth(src) { | |
| 614 | - | r, ok = selectionBounds.rangeForRow(d, src) | |
| 608 | + | width := d.RowWidth(src) | |
| 609 | + | cells, rangeCells := row[:n], row | |
| 610 | + | if n < width { | |
| 611 | + | cells = d.Row(src) | |
| 612 | + | rangeCells = cells | |
| 615 | 613 | } | |
| 614 | + | limit := contentEndOf(cells, bound) | |
| 615 | + | r, ok := selectionBounds.rangeForCells(src, rangeCells, limit) | |
| 616 | 616 | if ok { | |
| 617 | 617 | for x := max(r.Start, 0); x <= min(r.End, len(row)-1); x++ { | |
| 618 | 618 | toggleInverse(&row[x].Style) | |
| 619 | 619 | } | |
| 620 | - | if col, ok := selectionBounds.newlineMarkerAt(src, limit, d.RowWidth(src), bound.Soft); ok && col < len(row) { | |
| 620 | + | if col, ok := selectionBounds.newlineMarkerAt(src, limit, width, bound.Soft); ok && col < len(row) { | |
| 621 | 621 | toggleInverse(&row[col].Style) | |
| 622 | 622 | if cursorValid && cursor.Row == src && cursor.Col == col { | |
| 623 | 623 | cursorCovered = true | |
| @@ -605,19 +605,19 @@ func (m *Mode) RenderRowsRange(start, end int, paint func(int, []renderer.Cell), | |||||
| 605 | cursorCovered := false | 605 | cursorCovered := false | ||
| 606 | if hasSelectionBounds { | 606 | if hasSelectionBounds { | ||
| 607 | bound := d.snapshot.Bound(src) | 607 | bound := d.snapshot.Bound(src) | ||
| 608 | - | limit := contentEndOf(row[:n], bound) | 608 | + | width := d.RowWidth(src) |
| 609 | - | if n < d.RowWidth(src) { | 609 | + | cells, rangeCells := row[:n], row |
| 610 | - | limit = d.contentEnd(src) | 610 | + | if n < width { |
| 611 | - | } | 611 | + | cells = d.Row(src) |
| 612 | - | r, ok := selectionBounds.rangeForCells(src, row, limit) | 612 | + | rangeCells = cells |
| 613 | - | if n < d.RowWidth(src) { | |||
| 614 | - | r, ok = selectionBounds.rangeForRow(d, src) | |||
| 615 | } | 613 | } | ||
| 614 | + | limit := contentEndOf(cells, bound) | |||
| 615 | + | r, ok := selectionBounds.rangeForCells(src, rangeCells, limit) | |||
| 616 | if ok { | 616 | if ok { | ||
| 617 | 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++ { | ||
| 618 | toggleInverse(&row[x].Style) | 618 | toggleInverse(&row[x].Style) | ||
| 619 | } | 619 | } | ||
| 620 | - | if col, ok := selectionBounds.newlineMarkerAt(src, limit, d.RowWidth(src), bound.Soft); ok && col < len(row) { | 620 | + | if col, ok := selectionBounds.newlineMarkerAt(src, limit, width, bound.Soft); ok && col < len(row) { |
| 621 | toggleInverse(&row[col].Style) | 621 | toggleInverse(&row[col].Style) | ||
| 622 | if cursorValid && cursor.Row == src && cursor.Col == col { | 622 | if cursorValid && cursor.Row == src && cursor.Col == col { | ||
| 623 | cursorCovered = true | 623 | cursorCovered = true | ||