instead of clearing the search list when we delete, build a small part of it by searching through a small part that is likely to be visible on the user's screen, which gets rid of flickering effect and makes it look like the search list is not rebuilt from scratch
This commit is contained in:
@@ -388,11 +388,16 @@ struct
|
||||
fun helpRemoveChr (app: app_type, buffer, cursorIdx, count) =
|
||||
if count = 0 then
|
||||
let
|
||||
val searchString = #searchString app
|
||||
val buffer = LineGap.goToEnd buffer
|
||||
val initialMsg = [SEARCH (buffer, #searchString app)]
|
||||
val initialMsg = [SEARCH (buffer, searchString)]
|
||||
|
||||
val buffer = LineGap.goToIdx (cursorIdx + 777, buffer)
|
||||
val searchList =
|
||||
SearchList.buildRange (buffer, searchString, cursorIdx - 777)
|
||||
in
|
||||
Finish.buildTextAndClear
|
||||
(app, buffer, cursorIdx, SearchList.empty, initialMsg)
|
||||
(app, buffer, cursorIdx, searchList, initialMsg)
|
||||
end
|
||||
else
|
||||
let
|
||||
@@ -468,6 +473,10 @@ struct
|
||||
val searchString = #searchString app
|
||||
val initialMsg = [SEARCH (buffer, searchString)]
|
||||
|
||||
val buffer = LineGap.goToIdx (cursorIdx + 777, buffer)
|
||||
val searchList =
|
||||
SearchList.buildRange (buffer, searchString, cursorIdx - 777)
|
||||
|
||||
(* If we have deleted from the buffer so that cursorIdx
|
||||
* is no longer a valid idx,
|
||||
* clip cursorIdx to the end. *)
|
||||
@@ -475,7 +484,7 @@ struct
|
||||
val cursorIdx = Cursor.clipIdx (buffer, low)
|
||||
in
|
||||
Finish.buildTextAndClear
|
||||
(app, buffer, cursorIdx, SearchList.empty, initialMsg)
|
||||
(app, buffer, cursorIdx, searchList, initialMsg)
|
||||
end
|
||||
else
|
||||
let
|
||||
@@ -506,9 +515,13 @@ struct
|
||||
val buffer = LineGap.goToEnd buffer
|
||||
val initialMsg = [SEARCH (buffer, searchString)]
|
||||
|
||||
val buffer = LineGap.goToIdx (cursorIdx + 777, buffer)
|
||||
val searchList =
|
||||
SearchList.buildRange (buffer, searchString, cursorIdx - 777)
|
||||
|
||||
val buffer = LineGap.goToIdx (low, buffer)
|
||||
in
|
||||
Finish.buildTextAndClear (app, buffer, low, SearchList.empty, initialMsg)
|
||||
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg)
|
||||
end
|
||||
|
||||
fun deleteToEndOfLine (app: app_type) =
|
||||
@@ -549,10 +562,13 @@ struct
|
||||
val buffer = LineGap.goToEnd buffer
|
||||
val initialMsg = [SEARCH (buffer, searchString)]
|
||||
|
||||
val buffer = LineGap.goToIdx (cursorIdx + 777, buffer)
|
||||
val searchList =
|
||||
SearchList.buildRange (buffer, searchString, cursorIdx - 777)
|
||||
|
||||
val buffer = LineGap.goToIdx (startIdx, buffer)
|
||||
in
|
||||
Finish.buildTextAndClear
|
||||
(app, buffer, startIdx, SearchList.empty, initialMsg)
|
||||
Finish.buildTextAndClear (app, buffer, startIdx, searchList, initialMsg)
|
||||
end
|
||||
|
||||
fun helpDeleteLineBack (app, buffer, low, high, count) =
|
||||
@@ -566,10 +582,12 @@ struct
|
||||
val searchString = #searchString app
|
||||
val initialMsg = [SEARCH (buffer, searchString)]
|
||||
|
||||
val buffer = LineGap.goToIdx (low + 777, buffer)
|
||||
val searchList = SearchList.buildRange (buffer, searchString, low - 777)
|
||||
|
||||
val buffer = LineGap.goToIdx (low, buffer)
|
||||
in
|
||||
Finish.buildTextAndClear
|
||||
(app, buffer, low, SearchList.empty, initialMsg)
|
||||
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg)
|
||||
end
|
||||
else
|
||||
let
|
||||
@@ -619,8 +637,12 @@ struct
|
||||
|
||||
val buffer = LineGap.goToEnd buffer
|
||||
val initialMsg = [SEARCH (buffer, searchString)]
|
||||
|
||||
val buffer = LineGap.goToIdx (cursorIdx + 777, buffer)
|
||||
val searchList =
|
||||
SearchList.buildRange (buffer, searchString, cursorIdx - 777)
|
||||
in
|
||||
Finish.buildTextAndClear (app, buffer, low, SearchList.empty, initialMsg)
|
||||
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg)
|
||||
end
|
||||
|
||||
fun helpDeleteToChr
|
||||
@@ -635,9 +657,12 @@ struct
|
||||
val buffer = LineGap.goToEnd buffer
|
||||
val searchString = #searchString app
|
||||
val initialMsg = [SEARCH (buffer, searchString)]
|
||||
|
||||
val buffer = LineGap.goToIdx (cursorIdx + 777, buffer)
|
||||
val searchList =
|
||||
SearchList.buildRange (buffer, searchString, cursorIdx - 777)
|
||||
in
|
||||
buildTextAndClearAfterChr
|
||||
(app, buffer, low, SearchList.empty, initialMsg)
|
||||
buildTextAndClearAfterChr (app, buffer, low, searchList, initialMsg)
|
||||
end
|
||||
else
|
||||
let
|
||||
@@ -668,11 +693,14 @@ struct
|
||||
app
|
||||
|
||||
val buffer = LineGap.delete (0, cursorIdx, buffer)
|
||||
val searchList = SearchList.empty
|
||||
|
||||
val buffer = LineGap.goToEnd buffer
|
||||
val initialMsg = [SEARCH (buffer, #searchString app)]
|
||||
|
||||
val buffer = LineGap.goToIdx (cursorIdx + 777, buffer)
|
||||
val searchList =
|
||||
SearchList.buildRange (buffer, searchString, cursorIdx - 777)
|
||||
|
||||
val cursorIdx = 0
|
||||
val startLine = 0
|
||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
@@ -703,9 +731,12 @@ struct
|
||||
val buffer = LineGap.goToEnd buffer
|
||||
val initialMsg = [SEARCH (buffer, searchString)]
|
||||
|
||||
val buffer = LineGap.goToIdx (low + 777, buffer)
|
||||
val searchList = SearchList.buildRange (buffer, searchString, low - 777)
|
||||
|
||||
val buffer = LineGap.goToIdx (low, buffer)
|
||||
in
|
||||
Finish.buildTextAndClear (app, buffer, low, SearchList.empty, initialMsg)
|
||||
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg)
|
||||
end
|
||||
|
||||
fun deleteToNextMatch (app: app_type, count) =
|
||||
|
||||
@@ -159,6 +159,7 @@ struct
|
||||
|
||||
fun searchRange (buffer: LineGap.t, searchString, low) =
|
||||
let
|
||||
val low = Int.max (low, 0)
|
||||
val {rightStrings, leftStrings, idx = absIdx, ...} = buffer
|
||||
in
|
||||
case rightStrings of
|
||||
|
||||
Reference in New Issue
Block a user