From b5d070ada43fde1058381e2653220b752487a6bf Mon Sep 17 00:00:00 2001 From: Tommy Guo Date: Fri, 30 Jan 2026 14:37:02 -0500 Subject: [PATCH] fix(diff): make selection highlight apply to entire line --- internal/ui/model.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/ui/model.go b/internal/ui/model.go index 4db6d69..04414c6 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -3,6 +3,7 @@ package ui import ( "fmt" "math" + "regexp" "strconv" "strings" @@ -311,9 +312,8 @@ func (m Model) View() string { // --- DIFF VIEW HIGHLIGHT --- if m.focus == FocusDiff && i == m.diffCursor { - // FIXED: Uses DiffSelectionStyle (Background only) - // This keeps green/red text colors visible while adding the blue selection bar - line = DiffSelectionStyle.Render(line) + cleanLine := stripAnsi(line) + line = DiffSelectionStyle.Render(" " + cleanLine) } else { line = " " + line } @@ -386,3 +386,8 @@ func (m Model) View() string { return finalView } + +func stripAnsi(str string) string { + re := regexp.MustCompile("[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))") + return re.ReplaceAllString(str, "") +}