fix(diff): make selection highlight apply to entire line

This commit is contained in:
Tommy Guo 2026-01-30 14:37:02 -05:00
parent c9589fabf1
commit b5d070ada4

View File

@ -3,6 +3,7 @@ package ui
import ( import (
"fmt" "fmt"
"math" "math"
"regexp"
"strconv" "strconv"
"strings" "strings"
@ -311,9 +312,8 @@ func (m Model) View() string {
// --- DIFF VIEW HIGHLIGHT --- // --- DIFF VIEW HIGHLIGHT ---
if m.focus == FocusDiff && i == m.diffCursor { if m.focus == FocusDiff && i == m.diffCursor {
// FIXED: Uses DiffSelectionStyle (Background only) cleanLine := stripAnsi(line)
// This keeps green/red text colors visible while adding the blue selection bar line = DiffSelectionStyle.Render(" " + cleanLine)
line = DiffSelectionStyle.Render(line)
} else { } else {
line = " " + line line = " " + line
} }
@ -386,3 +386,8 @@ func (m Model) View() string {
return finalView 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, "")
}