fix(diff): make selection highlight apply to entire line
This commit is contained in:
parent
c9589fabf1
commit
b5d070ada4
|
|
@ -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, "")
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user