fix bugs in implementing and using text buffer. Some functions did not save the drawMsg to the app's state, which we means we didn't draw in those cases. The text builder functions also drew cursors on characters even when the cursor is not at this position. Both of these bugs are fixed.

This commit is contained in:
2025-09-12 23:21:53 +01:00
parent 77a64ae794
commit 422d6ad9ac
6 changed files with 14 additions and 16 deletions

View File

@@ -520,8 +520,8 @@ struct
val {buffer, cursorIdx, searchString, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val low = Cursor.prevWordStrict (buffer, cursorIdx, 1)
val high = Cursor.endOfWordStrict (buffer, cursorIdx, 1) + 1
val low = Cursor.prevWORDStrict (buffer, cursorIdx, 1)
val high = Cursor.endOfWORDStrict (buffer, cursorIdx, 1) + 1
val buffer = LineGap.goToIdx (high, buffer)
val length = high - low

View File

@@ -41,7 +41,7 @@ struct
)
val drawMsg = Vector.concat drawMsg
val drawMsg = DRAW_TEXT drawMsg
val drawMsg = [DRAW drawMsg]
val msgs = DRAW drawMsg :: msgs
val mode = NORMAL_MODE ""
in
@@ -91,7 +91,7 @@ struct
val newBuffer = LineGap.goToIdx (cursorIdx, buffer)
val visualScrollColumn =
TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
TextScroll.getScrollColumn (buffer, cursorIdx, newWidth)
val newBuffer = LineGap.goToLine (startLine, newBuffer)
val lineIdx = TextBuilderUtils.getLineAbsIdxFromBuffer (startLine, buffer)
@@ -99,15 +99,15 @@ struct
( startLine
, cursorIdx
, buffer
, windowWidth
, windowHeight
, newWidth
, newHeight
, searchList
, searchString
, visualScrollColumn
)
val drawMsg = Vector.concat drawMsg
val drawMsg = DRAW_TEXT drawMsg
val drawMsg = [DRAW drawMsg]
val msgs = [DRAW drawMsg]
in
NormalModeWith.bufferAndSize
( app
@@ -115,7 +115,7 @@ struct
, newWidth
, newHeight
, searchList
, drawMsg
, msgs
, bufferModifyTime
, visualScrollColumn
)
@@ -159,7 +159,7 @@ struct
)
val drawMsg = Vector.concat drawMsg
val drawMsg = DRAW_TEXT drawMsg
val drawMsg = [DRAW drawMsg]
val msgs = DRAW drawMsg :: initialMsg
val mode = NORMAL_MODE ""
in
@@ -170,7 +170,7 @@ struct
, mode
, startLine
, searchList
, drawMsg
, msgs
, bufferModifyTime
, visualScrollColumn
)

View File

@@ -84,7 +84,7 @@ struct
val drawMsg = NormalModeTextBuilder.build
( bufferLine
, lineIdx
, bufferIdx
, buffer
, windowWidth
, windowHeight

View File

@@ -27,7 +27,6 @@ struct
(* get relative index of line to start building from *)
val strPos =
Utils.getRelativeLineStartFromRightHead (startLine, curLine, lhd)
+ 1
(* get absolute idx of line *)
val absIdx = curIdx + strPos
val searchPos = BinSearch.equalOrMore (absIdx, searchList)

View File

@@ -207,8 +207,7 @@ struct
in Utils.makeCursorOnChr (chr, posX, posY, env) :: acc
end
else
Utils.makeChr (chr, posX, posY, env)
:: Utils.makeCursor (posX, posY, env) :: acc
Utils.makeChr (chr, posX, posY, env) :: acc
in
build
( pos + 1

View File

@@ -270,8 +270,8 @@ struct
let
val acc =
if absIdx = cursorIdx then
Utils.makeCursor (posX, posY, env)
:: Utils.makeCursorOnChr (chr, posX, posY, env) :: acc
Utils.makeCursorOnChr (chr, posX, posY, env)
:: Utils.makeCursor (posX, posY, env) :: acc
else if Utils.isInSearchRange (absIdx, searchPos, env) then
Utils.makeHighlightChr (chr, posX, posY, env)
:: Utils.makeHighlight (posX, posY, env) :: acc