From 0f743cf1b3238b7803c72743f7f8d434d4f33334 Mon Sep 17 00:00:00 2001 From: "Luke I. Wilson" Date: Tue, 16 Mar 2021 14:07:11 -0500 Subject: [PATCH] Selection drawing fixes when scrolling in TextEdit --- ui/textedit.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/textedit.go b/ui/textedit.go index bd90a62..42da848 100644 --- a/ui/textedit.go +++ b/ui/textedit.go @@ -387,12 +387,13 @@ func (t *TextEdit) Draw(s tcell.Screen) { // If the current line is part of a selected region... if t.selectMode && line >= t.selection.StartLine && line <= t.selection.EndLine { - selStartIdx := 0 + selStartIdx := t.scrollx if line == t.selection.StartLine { // If the selection begins somewhere in the line... + // Account for hard tabs tabCount := t.getTabCountInLineAtCol(line, t.selection.StartCol) selStartIdx = t.selection.StartCol + tabCount*(t.TabSize-1) - t.scrollx } - selEndIdx := len(lineRunes) // Not inclusive + selEndIdx := len(lineRunes)-t.scrollx // Not inclusive if line == t.selection.EndLine { // If the selection ends somewhere in the line... tabCount := t.getTabCountInLineAtCol(line, t.selection.EndCol) selEndIdx = t.selection.EndCol + 1 + tabCount*(t.TabSize-1) - t.scrollx