Skip to content

Commit 90acf2f

Browse files
authored
Merge pull request #54 from Terminal239/bug/horizontal-scroll-fix
fix: Horizontal Scroll Causes Complete Overflow
2 parents 0a11387 + 5119680 commit 90acf2f

1 file changed

Lines changed: 19 additions & 33 deletions

File tree

internal/tui/program.go

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
package tui
22

33
import (
4-
"fmt"
5-
"sort"
6-
"strings"
4+
"fmt"
5+
"sort"
76
"strconv"
8-
"time"
7+
"strings"
8+
"time"
99
"unicode/utf8"
1010

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"
1919
)
2020

2121
const (
@@ -1902,12 +1902,8 @@ func (m model) rightBodyLinesAll(width int) []string {
19021902
} else {
19031903
l := m.renderSideCell(r, "left", colsW)
19041904
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)
19111907
lines = append(lines, l+mid+rr)
19121908
}
19131909
}
@@ -2606,14 +2602,10 @@ func (m model) renderSideCell(r diffview.Row, side string, width int) string {
26062602
return ansi.Truncate(marker+" ", width, "")
26072603
}
26082604
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
26172609
}
26182610

26192611
// renderSideCellWrap renders a cell like renderSideCell but wraps the content
@@ -2672,13 +2664,7 @@ func sliceANSI(s string, start, w int) string {
26722664
}
26732665
// First keep only the left portion up to start+w, then drop the first `start` columns.
26742666
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, "")
26822668
}
26832669

26842670
// padExact pads s with spaces to exactly width w (ANSI-aware width).

0 commit comments

Comments
 (0)