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:
@@ -15,13 +15,12 @@ struct
|
|||||||
val posY = posY + TC.ySpace
|
val posY = posY + TC.ySpace
|
||||||
val lineNumber = lineNumber + 1
|
val lineNumber = lineNumber + 1
|
||||||
in
|
in
|
||||||
build
|
skipToFirstVisibleColumn
|
||||||
( strPos
|
( strPos
|
||||||
, shd
|
, shd
|
||||||
, stl
|
, stl
|
||||||
, lhd
|
, lhd
|
||||||
, ltl
|
, ltl
|
||||||
, #startX env
|
|
||||||
, posY
|
, posY
|
||||||
, 0
|
, 0
|
||||||
, lineNumber
|
, lineNumber
|
||||||
@@ -78,13 +77,12 @@ struct
|
|||||||
val posY = posY + TC.ySpace
|
val posY = posY + TC.ySpace
|
||||||
val lineNumber = lineNumber + 1
|
val lineNumber = lineNumber + 1
|
||||||
in
|
in
|
||||||
build
|
skipToFirstVisibleColumn
|
||||||
( newStrPos
|
( newStrPos
|
||||||
, str
|
, str
|
||||||
, stl
|
, stl
|
||||||
, line
|
, line
|
||||||
, ltl
|
, ltl
|
||||||
, #startX env
|
|
||||||
, posY
|
, posY
|
||||||
, 0
|
, 0
|
||||||
, lineNumber
|
, lineNumber
|
||||||
@@ -150,19 +148,23 @@ struct
|
|||||||
case String.sub (str, pos) of
|
case String.sub (str, pos) of
|
||||||
#"\n" =>
|
#"\n" =>
|
||||||
let
|
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 posY = posY + TC.ySpace
|
||||||
val lineNumber = lineNumber + 1
|
val lineNumber = lineNumber + 1
|
||||||
in
|
in
|
||||||
build
|
skipToFirstVisibleColumn
|
||||||
( pos + 1
|
( pos + 1
|
||||||
, str
|
, str
|
||||||
, stl
|
, stl
|
||||||
, line
|
, line
|
||||||
, ltl
|
, ltl
|
||||||
, #startX env
|
|
||||||
, posY
|
, posY
|
||||||
, #scrollColumnStart env
|
, 0
|
||||||
, lineNumber
|
, lineNumber
|
||||||
, absIdx + 1
|
, absIdx + 1
|
||||||
, cursorIdx
|
, cursorIdx
|
||||||
|
|||||||
8
temp.txt
8
temp.txt
@@ -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 =
|
structure TextBuilder :> TEXT_BUILDER =
|
||||||
struct
|
struct
|
||||||
val xSpace = 13
|
val xSpace = 13
|
||||||
|
|||||||
Reference in New Issue
Block a user