mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
widget: optimize painting editor selection
This commit introduces logic to skip painting the selection rectangle on lines prior to the line containing the beginning of the selection. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
@@ -680,6 +680,11 @@ func (e *Editor) PaintSelection(gtx layout.Context) {
|
||||
for !posIsBelow(e.lines, pos, cl.Max.Y) {
|
||||
start, end := clipLine(e.lines, e.Alignment, e.viewSize.X, cl, pos)
|
||||
lineIdx := start.lineCol.Y
|
||||
if lineIdx < caretStart.lineCol.Y {
|
||||
// Line is before selection start; skip.
|
||||
pos = e.closestPosition(combinedPos{lineCol: screenPos{Y: pos.lineCol.Y + 1}})
|
||||
continue
|
||||
}
|
||||
if lineIdx > caretEnd.lineCol.Y {
|
||||
// Line is after selection end; we're done.
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user