From 580f01448190882ff5fa9955a811d315242fc0e9 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Thu, 11 Sep 2025 17:09:43 +0100 Subject: [PATCH] fix getScrollColumn calculation: the right calculation is to subtract the column number by how many columns we can fit --- fcore/normal-mode/normal-finish.sml | 1 + fcore/text-scroll.sml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fcore/normal-mode/normal-finish.sml b/fcore/normal-mode/normal-finish.sml index 95dd165..1dabf31 100644 --- a/fcore/normal-mode/normal-finish.sml +++ b/fcore/normal-mode/normal-finish.sml @@ -17,6 +17,7 @@ struct (* calculate scroll column *) val buffer = LineGap.goToIdx (cursorIdx, buffer) val visualScrollColumn = TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth) + val () = print (Int.toString visualScrollColumn ^ "\n") (* move LineGap to first line displayed on screen *) val buffer = LineGap.goToLine (startLine, buffer) diff --git a/fcore/text-scroll.sml b/fcore/text-scroll.sml index be2842c..0fea775 100644 --- a/fcore/text-scroll.sml +++ b/fcore/text-scroll.sml @@ -16,7 +16,9 @@ struct if windowWidth >= TC.textLineWidth then TC.textLineCount else windowWidth div TC.xSpace in - columnDifference mod howManyColumnsCanWeFit + if columnDifference < howManyColumnsCanWeFit then 0 + else + columnDifference - howManyColumnsCanWeFit end end end