a few bug fixes to NORMAL_SEARCH_MODE: the main one is that we were passing the general searchString to the resize function before, and we were drawing the wrong string because of that; another bug fix is that, on resizing, we have to update the mode to contain the recalculated searchScrollColumn

This commit is contained in:
2025-09-14 10:28:42 +01:00
parent 0632f7a969
commit 9b34014af1
3 changed files with 26 additions and 34 deletions

View File

@@ -82,23 +82,30 @@ struct
( app: app_type ( app: app_type
, newWindowWidth , newWindowWidth
, newWindowHeight , newWindowHeight
, searchString
, searchCursorIdx , searchCursorIdx
, tempSearchList , tempSearchList
, searchScrollColumn , searchScrollColumn
) = ) =
let let
val val
{ buffer {buffer, cursorIdx, startLine = prevLineNumber, visualScrollColumn, ...} =
, cursorIdx app
, startLine = prevLineNumber
, searchString
, visualScrollColumn
, ...
} = app
val floatWindowWidth = Real32.fromInt newWindowWidth val floatWindowWidth = Real32.fromInt newWindowWidth
val floatWindowHeight = Real32.fromInt newWindowHeight val floatWindowHeight = Real32.fromInt newWindowHeight
val searchScrollColumn =
TextScroll.getScrollColumnFromString
(searchCursorIdx, newWindowWidth, searchScrollColumn)
val mode = NORMAL_SEARCH_MODE
{ searchString = searchString
, tempSearchList = tempSearchList
, searchCursorIdx = searchCursorIdx
, searchScrollColumn = searchScrollColumn
}
val searchStringPosY = newWindowHeight - TextConstants.ySpace - 5 val searchStringPosY = newWindowHeight - TextConstants.ySpace - 5
val initialTextAcc = SearchBar.build val initialTextAcc = SearchBar.build
@@ -112,28 +119,6 @@ struct
, searchScrollColumn , searchScrollColumn
) )
val cursor =
let
val xpos = TextConstants.xSpace * (searchCursorIdx + 1) + 5
val x = Real32.fromInt xpos
val y = Real32.fromInt searchStringPosY
val r: Real32.real = 0.67
val g: Real32.real = 0.51
val b: Real32.real = 0.83
in
PipeCursor.lerp
( x
, y
, 0.01
, TextConstants.scale
, floatWindowWidth
, floatWindowHeight
, r
, g
, b
)
end
val buffer = LineGap.goToIdx (cursorIdx, buffer) val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorLine = LineGap.getLineNumberOfIdx (cursorIdx, buffer) val cursorLine = LineGap.getLineNumberOfIdx (cursorIdx, buffer)
val startLine = val startLine =
@@ -153,13 +138,13 @@ struct
, tempSearchList , tempSearchList
, searchString , searchString
, visualScrollColumn , visualScrollColumn
, cursor :: initialTextAcc , initialTextAcc
) )
val drawMsg = Vector.concat drawMsg val drawMsg = Vector.concat drawMsg
val drawMsg = DrawMsg.DRAW_TEXT drawMsg val drawMsg = DrawMsg.DRAW_TEXT drawMsg
val msgs = [MailboxType.DRAW drawMsg] val msgs = [MailboxType.DRAW drawMsg]
in in
NormalSearchModeWith.bufferAndSize NormalSearchModeWith.bufferAndSize
(app, buffer, newWindowWidth, newWindowHeight, msgs) (app, mode, buffer, newWindowWidth, newWindowHeight, msgs)
end end
end end

View File

@@ -102,10 +102,16 @@ struct
end end
fun bufferAndSize fun bufferAndSize
(app: app_type, newBuffer, newWindowWidth, newWindowHeight, newMsgs) = ( app: app_type
, newMode
, newBuffer
, newWindowWidth
, newWindowHeight
, newMsgs
) =
let let
val val
{ mode { mode = _
, windowWidth = _ , windowWidth = _
, windowHeight = _ , windowHeight = _
, msgs = _ , msgs = _
@@ -118,7 +124,7 @@ struct
, visualScrollColumn , visualScrollColumn
} = app } = app
in in
{ mode = mode { mode = newMode
, buffer = newBuffer , buffer = newBuffer
, windowWidth = newWindowWidth , windowWidth = newWindowWidth
, windowHeight = newWindowHeight , windowHeight = newWindowHeight

View File

@@ -213,6 +213,7 @@ struct
( app ( app
, width , width
, height , height
, searchString
, searchCursorIdx , searchCursorIdx
, tempSearchList , tempSearchList
, searchScrollColumn , searchScrollColumn