fix bug where some lines were not scrolling horizontally properly. The issue was that, when encountering a line break in 'skipToFirstVisualColumn' function, we should have recursively called the 'skipToFirstVisualColumn' function instead of the 'build' function. The reason is that our current column after a line break is 0, but we don't know if the start column to display is necessarily 0 in all cases.

This commit is contained in:
2025-09-13 00:14:07 +01:00
parent b9e2da3ff9
commit 295bdc35cf
2 changed files with 10 additions and 16 deletions

View File

@@ -15,13 +15,12 @@ struct
val posY = posY + TC.ySpace
val lineNumber = lineNumber + 1
in
build
skipToFirstVisibleColumn
( strPos
, shd
, stl
, lhd
, ltl
, #startX env
, posY
, 0
, lineNumber
@@ -78,13 +77,12 @@ struct
val posY = posY + TC.ySpace
val lineNumber = lineNumber + 1
in
build
skipToFirstVisibleColumn
( newStrPos
, str
, stl
, line
, ltl
, #startX env
, posY
, 0
, lineNumber
@@ -150,19 +148,23 @@ struct
case String.sub (str, pos) of
#"\n" =>
let
(* increment line lineNumber and posY, and then call build function *)
(* increment line lineNumber and posY,
* and then call skipToFirstVisibleColumn recursively.
* The recursive call check this condition:
* Is the new column 0 the same as the column the scroll starts at?
* If it is, then we call build, or else we continue skipping
* until we reach the start column. *)
val posY = posY + TC.ySpace
val lineNumber = lineNumber + 1
in
build
skipToFirstVisibleColumn
( pos + 1
, str
, stl
, line
, ltl
, #startX env
, posY
, #scrollColumnStart env
, 0
, lineNumber
, absIdx + 1
, cursorIdx

View File

@@ -1,11 +1,3 @@
signature TEXT_BUILDER = aaron baron carrot durian
(* Prerequisite: LineGap is moved to requested line first. *)
val build: int * int * LineGap.t * int * int
-> MailboxType.t list
end
structure TextBuilder :> TEXT_BUILDER =
struct
val xSpace = 13