Selection drawing fixes when scrolling in TextEdit
This commit is contained in:
parent
5a3bae052b
commit
0f743cf1b3
@ -387,12 +387,13 @@ func (t *TextEdit) Draw(s tcell.Screen) {
|
|||||||
|
|
||||||
// If the current line is part of a selected region...
|
// If the current line is part of a selected region...
|
||||||
if t.selectMode && line >= t.selection.StartLine && line <= t.selection.EndLine {
|
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...
|
if line == t.selection.StartLine { // If the selection begins somewhere in the line...
|
||||||
|
// Account for hard tabs
|
||||||
tabCount := t.getTabCountInLineAtCol(line, t.selection.StartCol)
|
tabCount := t.getTabCountInLineAtCol(line, t.selection.StartCol)
|
||||||
selStartIdx = t.selection.StartCol + tabCount*(t.TabSize-1) - t.scrollx
|
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...
|
if line == t.selection.EndLine { // If the selection ends somewhere in the line...
|
||||||
tabCount := t.getTabCountInLineAtCol(line, t.selection.EndCol)
|
tabCount := t.getTabCountInLineAtCol(line, t.selection.EndCol)
|
||||||
selEndIdx = t.selection.EndCol + 1 + tabCount*(t.TabSize-1) - t.scrollx
|
selEndIdx = t.selection.EndCol + 1 + tabCount*(t.TabSize-1) - t.scrollx
|
||||||
|
Loading…
x
Reference in New Issue
Block a user