From 0487db8b993bafa0a7a780a7872f52796de9b619 Mon Sep 17 00:00:00 2001 From: Dmitry Maluka Date: Wed, 3 Mar 2021 20:09:35 +0100 Subject: [PATCH] Fix horizontal scrolling with a wide rune at the right edge of window --- internal/display/bufwindow.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/display/bufwindow.go b/internal/display/bufwindow.go index 87bf27a5..e493547b 100644 --- a/internal/display/bufwindow.go +++ b/internal/display/bufwindow.go @@ -208,12 +208,17 @@ func (w *BufWindow) Relocate() bool { // horizontal relocation (scrolling) if !b.Settings["softwrap"].(bool) { cx := activeC.GetVisualX() + rw := runewidth.RuneWidth(activeC.RuneUnder(activeC.X)) + if rw == 0 { + rw = 1 // tab or newline + } + if cx < w.StartCol { w.StartCol = cx ret = true } - if cx+w.gutterOffset+1 > w.StartCol+w.Width { - w.StartCol = cx - w.Width + w.gutterOffset + 1 + if cx+w.gutterOffset+rw > w.StartCol+w.Width { + w.StartCol = cx - w.Width + w.gutterOffset + rw ret = true } }