From 66ca16f836f70d90ab751dcc804bf158f0c5ae48 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 11 Feb 2025 23:41:13 +0900 Subject: Truncate wrap signs in extremely narrow preview window --- src/tui/tcell.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/tui/tcell.go') diff --git a/src/tui/tcell.go b/src/tui/tcell.go index b70eed48..dffd235f 100644 --- a/src/tui/tcell.go +++ b/src/tui/tcell.go @@ -766,10 +766,18 @@ Loop: xPos := w.left + w.lastX + lx if xPos >= w.left+w.width { w.lastY++ + if w.lastY >= w.height { + return FillSuspend + } w.lastX = 0 lx = 0 xPos = w.left - wgr := uniseg.NewGraphemes(w.wrapSign) + sign := w.wrapSign + if w.wrapSignWidth > w.width { + runes, _ := util.Truncate(sign, w.width) + sign = string(runes) + } + wgr := uniseg.NewGraphemes(sign) for wgr.Next() { rs := wgr.Runes() _screen.SetContent(w.left+lx, w.top+w.lastY, rs[0], rs[1:], style.Dim(true)) -- cgit v1.2.3