Skip to content

Commit ac355fe

Browse files
authored
fix(renderer): restore tab stops if hard tabs are enabled (#1677)
When hard tabs are enabled, we optimize rendering by using actual tab characters instead of spaces. This requires us to set tab stops every 8 columns at the beginning of the rendering process. Fixes: #1614
1 parent d81b6b6 commit ac355fe

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

cursed_renderer.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ func (s *cursedRenderer) setOptimizations(hardTabs, backspace, mapnl bool) {
6161
s.hardTabs = hardTabs
6262
s.backspace = backspace
6363
s.mapnl = mapnl
64-
s.scr.SetTabStops(s.width)
64+
if s.hardTabs {
65+
s.scr.SetTabStops(s.width)
66+
} else {
67+
s.scr.SetTabStops(-1)
68+
}
6569
s.scr.SetBackspace(s.backspace)
6670
s.scr.SetMapNewline(s.mapnl)
6771
s.mu.Unlock()
@@ -275,6 +279,11 @@ func (s *cursedRenderer) flush(closing bool) error {
275279
}
276280
}
277281

282+
// Restore tab stops if we have tab optimizations enabled.
283+
if s.starting && s.hardTabs {
284+
_, _ = s.scr.WriteString(ansi.SetTabEvery8Columns)
285+
}
286+
278287
if !s.starting && !closing && s.lastView != nil && viewEquals(s.lastView, &view) && frameArea == s.cellbuf.Bounds() {
279288
// No changes, nothing to do.
280289
return nil
@@ -587,7 +596,11 @@ func reset(s *cursedRenderer) {
587596
scr.SetColorProfile(s.profile)
588597
scr.SetRelativeCursor(true) // Always start in inline mode
589598
scr.SetFullscreen(false) // Always start in inline mode
590-
scr.SetTabStops(s.width)
599+
if s.hardTabs {
600+
scr.SetTabStops(s.width)
601+
} else {
602+
scr.SetTabStops(-1)
603+
}
591604
scr.SetBackspace(s.backspace)
592605
scr.SetMapNewline(s.mapnl)
593606
scr.SetScrollOptim(runtime.GOOS != "windows") // disable scroll optimization on Windows due to bugs in some terminals
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[>4m[=0;1u[?1049h[?25l[?2004h[>4;2m[=1;1usuccess[>4m[=0;1u[?1049l[?25h[?2004l[?2026$p[?2027$p
1+
[>4m[=0;1u[?1049h[?25l[?2004h[>4;2m[=1;1usuccess[>4m[=0;1u[?1049l[?25h[?2004l[?2026$p[?2027$p

0 commit comments

Comments
 (0)