diff kitten: Use a words based algorithm for intra line changed region highlighting

Fixes #9598
This commit is contained in:
copilot-swe-agent[bot]
2026-03-03 16:33:59 +00:00
committed by Kovid Goyal
parent cbfc60aa4f
commit 1785873835
4 changed files with 387 additions and 17 deletions

View File

@@ -568,13 +568,18 @@ func splitlines(text string, width int) []string {
}
func render_half_line(line_number int, line, ltype string, available_cols int, center Center, ans []HalfScreenLine) []HalfScreenLine {
size := center.left_size
if ltype != "remove" {
size = center.right_size
var regions []Region
if ltype == "remove" {
regions = center.left_regions
} else {
regions = center.right_regions
}
if size > 0 {
span := center_span(ltype, center.offset, size)
line = sgr.InsertFormatting(line, span)
if len(regions) > 0 {
spans := make([]*sgr.Span, len(regions))
for i, r := range regions {
spans[i] = center_span(ltype, r.offset, r.size)
}
line = sgr.InsertFormatting(line, spans...)
}
lnum := strconv.Itoa(line_number + 1)
for _, sc := range splitlines(line, available_cols) {