Skip to content
Myr

fix(renderer): restore tab stops if hard tabs are enabled (#1677)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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.

authored by Ayman Bagabas · committed by GitHub · parent d81b6b6 · Browse files · 2 files+16 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Fixes: https://github.com/charmbracelet/bubbletea/issues/1614

Diff stats

2 files+16 added−3 removed

  • other:+16 added−3 removed

2 files+16 added−3 removed

modified:testdata/TestViewModel/altscreen_autoexit.golden+1 added-1 removed
1[>4m[=0;1u[?1049h[?25l[?2004h[>4;2m[=1;1usuccess[>4m[=0;1u [?1049l[?25h[?2004l[?2026$p[?2027$p1[>4m[=0;1u[?1049h[?25l[?2004h[>4;2m[=1;1usuccess[>4m[=0;1u[?1049l[?25h[?2004l[?2026$p[?2027$p
modified:cursed_renderer.go+15 added-2 removed
59 unmodified lines
60 s.mu.Lock()61 s.hardTabs = hardTabs62 s.backspace = backspace63 s.mapnl = mapnl64 if s.hardTabs {64 s.scr.SetTabStops(s.width)65 s.scr.SetTabStops(s.width)66 } else {67 s.scr.SetTabStops(-1)68 }69 s.scr.SetBackspace(s.backspace)70 s.scr.SetMapNewline(s.mapnl)71 s.mu.Unlock()72}
205 unmodified lines
278 frameArea.Max.Y = frameHeight279 }280 }281282 // Restore tab stops if we have tab optimizations enabled.283 if s.starting && s.hardTabs {284 _, _ = s.scr.WriteString(ansi.SetTabEvery8Columns)285 }286287 if !s.starting && !closing && s.lastView != nil && viewEquals(s.lastView, &view) && frameArea == s.cellbuf.Bounds() {288 // No changes, nothing to do.289 return nil290 }
304 unmodified lines
595 scr := uv.NewTerminalRenderer(&s.buf, s.env)596 scr.SetColorProfile(s.profile)597 scr.SetRelativeCursor(true) // Always start in inline mode598 scr.SetFullscreen(false) // Always start in inline mode599 if s.hardTabs {590 scr.SetTabStops(s.width)600 scr.SetTabStops(s.width)601 } else {602 scr.SetTabStops(-1)603 }604 scr.SetBackspace(s.backspace)605 scr.SetMapNewline(s.mapnl)606 scr.SetScrollOptim(runtime.GOOS != "windows") // disable scroll optimization on Windows due to bugs in some terminals607 s.scr = scr
247 unmodified lines