|
1 | 1 | package tui |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "fmt" |
5 | | - "sort" |
6 | | - "strings" |
| 4 | + "fmt" |
| 5 | + "sort" |
7 | 6 | "strconv" |
8 | | - "time" |
| 7 | + "strings" |
| 8 | + "time" |
9 | 9 | "unicode/utf8" |
10 | 10 |
|
11 | | - "github.com/charmbracelet/bubbles/textinput" |
12 | | - "github.com/charmbracelet/bubbles/viewport" |
13 | | - tea "github.com/charmbracelet/bubbletea" |
14 | | - "github.com/charmbracelet/lipgloss" |
15 | | - "github.com/charmbracelet/x/ansi" |
16 | | - "github.com/interpretive-systems/diffium/internal/diffview" |
17 | | - "github.com/interpretive-systems/diffium/internal/gitx" |
18 | | - "github.com/interpretive-systems/diffium/internal/prefs" |
| 11 | + "github.com/charmbracelet/bubbles/textinput" |
| 12 | + "github.com/charmbracelet/bubbles/viewport" |
| 13 | + tea "github.com/charmbracelet/bubbletea" |
| 14 | + "github.com/charmbracelet/lipgloss" |
| 15 | + "github.com/charmbracelet/x/ansi" |
| 16 | + "github.com/interpretive-systems/diffium/internal/diffview" |
| 17 | + "github.com/interpretive-systems/diffium/internal/gitx" |
| 18 | + "github.com/interpretive-systems/diffium/internal/prefs" |
19 | 19 | ) |
20 | 20 |
|
21 | 21 | const ( |
@@ -1902,12 +1902,8 @@ func (m model) rightBodyLinesAll(width int) []string { |
1902 | 1902 | } else { |
1903 | 1903 | l := m.renderSideCell(r, "left", colsW) |
1904 | 1904 | rr := m.renderSideCell(r, "right", colsW) |
1905 | | - if m.rightXOffset > 0 { |
1906 | | - l = sliceANSI(l, m.rightXOffset, colsW) |
1907 | | - rr = sliceANSI(rr, m.rightXOffset, colsW) |
1908 | | - l = padExact(l, colsW) |
1909 | | - rr = padExact(rr, colsW) |
1910 | | - } |
| 1905 | + l = padExact(l, colsW) |
| 1906 | + rr = padExact(rr, colsW) |
1911 | 1907 | lines = append(lines, l+mid+rr) |
1912 | 1908 | } |
1913 | 1909 | } |
@@ -2606,14 +2602,10 @@ func (m model) renderSideCell(r diffview.Row, side string, width int) string { |
2606 | 2602 | return ansi.Truncate(marker+" ", width, "") |
2607 | 2603 | } |
2608 | 2604 | bodyW := width - 2 |
2609 | | - // First clip right side to avoid wrapping |
2610 | | - clipped := clipToWidth(content, bodyW) |
2611 | | - // Then apply horizontal slice if any |
2612 | | - if m.rightXOffset > 0 { |
2613 | | - clipped = sliceANSI(clipped, m.rightXOffset, bodyW) |
2614 | | - } |
2615 | | - body := padExact(clipped, bodyW) |
2616 | | - return marker + " " + body |
| 2605 | + |
| 2606 | + clipped := sliceANSI(content, m.rightXOffset, bodyW) |
| 2607 | + |
| 2608 | + return marker + " " + clipped |
2617 | 2609 | } |
2618 | 2610 |
|
2619 | 2611 | // renderSideCellWrap renders a cell like renderSideCell but wraps the content |
@@ -2672,13 +2664,7 @@ func sliceANSI(s string, start, w int) string { |
2672 | 2664 | } |
2673 | 2665 | // First keep only the left portion up to start+w, then drop the first `start` columns. |
2674 | 2666 | head := ansi.Truncate(s, start+w, "") |
2675 | | - return ansi.TruncateLeft(head, w, "") |
2676 | | -} |
2677 | | - |
2678 | | -// clipToWidth trims the string to at most w cells without ellipsis. |
2679 | | -func clipToWidth(s string, w int) string { |
2680 | | - if w <= 0 { return "" } |
2681 | | - return ansi.Truncate(s, w, "") |
| 2667 | + return ansi.TruncateLeft(head, start, "") |
2682 | 2668 | } |
2683 | 2669 |
|
2684 | 2670 | // padExact pads s with spaces to exactly width w (ANSI-aware width). |
|
0 commit comments