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 (
"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, "")
}