Side-by-side semantic diff tool with theme support and hookable integration
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: show file names above each column instead of arrow header

+22 -6
docs/screenshot.png

This is a binary file and will not be displayed.

+1 -1
flake.nix
··· 147 147 Set Shell "bash" 148 148 Set FontSize 14 149 149 Set Width 1600 150 - Set Height 600 150 + Set Height 900 151 151 152 152 Env COLORTERM "truecolor" 153 153 Env TERM "xterm-256color"
+21 -5
main.go
··· 299 299 st := m.styles 300 300 var sb strings.Builder 301 301 302 - // Header 303 - sb.WriteString(st.HeaderSt.Render(fmt.Sprintf(" %s → %s", m.oldFile, m.newFile))) 304 - sb.WriteString("\n") 305 - 306 302 colWidth := m.width / 2 307 303 if colWidth < 10 { 308 304 colWidth = 10 309 305 } 306 + 307 + // Header: file names above each column, │ unstyled to match data rows 308 + lh := fitName(m.oldFile, colWidth-1) 309 + rh := fitName(m.newFile, colWidth-1) 310 + sb.WriteString(st.HeaderSt.Render(" "+lh) + " │ " + st.HeaderSt.Render(rh)) 311 + sb.WriteString("\n") 312 + sb.WriteString(strings.Repeat(" ", colWidth+1) + " │ " + strings.Repeat(" ", colWidth-1)) 313 + sb.WriteString("\n") 310 314 311 315 start := m.offset 312 316 end := start + m.height ··· 377 381 return sb.String() 378 382 } 379 383 384 + // fitName truncates or pads s to exactly width runes. 385 + func fitName(s string, width int) string { 386 + runes := []rune(s) 387 + if len(runes) > width { 388 + return string(runes[:width-1]) + "…" 389 + } 390 + return s + strings.Repeat(" ", width-len(runes)) 391 + } 392 + 380 393 // getHighlightedLine returns the highlighted line at index idx (0-based). 381 394 func (m model) getHighlightedLine(hl []string, idx int) string { 382 395 if idx < 0 || idx >= len(hl) { ··· 416 429 colWidth = 10 417 430 } 418 431 419 - fmt.Println(st.HeaderSt.Render(fmt.Sprintf(" %s → %s", m.oldFile, m.newFile))) 432 + lh := fitName(m.oldFile, colWidth-1) 433 + rh := fitName(m.newFile, colWidth-1) 434 + fmt.Println(st.HeaderSt.Render(" "+lh) + " │ " + st.HeaderSt.Render(rh)) 435 + fmt.Println(strings.Repeat(" ", colWidth+1) + " │ " + strings.Repeat(" ", colWidth-1)) 420 436 421 437 for _, dl := range m.lines { 422 438 leftLine := m.getHighlightedLine(m.oldHL, dl.OldLine-1)