Skip to content

Commit 7e36f7c

Browse files
committed
Nicer selection highlight
The selection highlight will now have the same width as the text it highlights. Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
1 parent eb8adcd commit 7e36f7c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

pkg/tui/components/messages/messages.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,15 +945,17 @@ func (m *model) applySelectionHighlight(lines []string, viewportStartLine int) [
945945
case absoluteLine == startLine:
946946
// Start of multi-line selection
947947
plainLine := ansi.Strip(line)
948-
lineWidth := runewidth.StringWidth(plainLine)
948+
trimmedLine := strings.TrimRight(plainLine, " \t")
949+
lineWidth := runewidth.StringWidth(trimmedLine)
949950
highlighted[i] = m.highlightLine(line, startCol, lineWidth)
950951
case absoluteLine == endLine:
951952
// End of multi-line selection
952953
highlighted[i] = m.highlightLine(line, 0, endCol)
953954
default:
954955
// Middle of multi-line selection
955956
plainLine := ansi.Strip(line)
956-
lineWidth := runewidth.StringWidth(plainLine)
957+
trimmedLine := strings.TrimRight(plainLine, " \t")
958+
lineWidth := runewidth.StringWidth(trimmedLine)
957959
highlighted[i] = m.highlightLine(line, 0, lineWidth)
958960
}
959961
}

0 commit comments

Comments
 (0)