progress addressing to-do notes in fcore/normal-mode/make-normal-delete.sml, although some notes are still left. The notes that have been addressed involved cases where we create a new buffer containing just a newline, because all of the text in the buffer has been deleted otherwise. In this case, we call 'SearchList.build' and build the search-list from scratch, which is fast because only one character needs to be checked.
This commit is contained in:
@@ -50,6 +50,7 @@ struct
|
|||||||
(* deleted whole file; add newline to the end *)
|
(* deleted whole file; add newline to the end *)
|
||||||
let
|
let
|
||||||
val buffer = LineGap.append ("\n", buffer)
|
val buffer = LineGap.append ("\n", buffer)
|
||||||
|
val (buffer, searchList) = SearchList.build (buffer, #dfa app)
|
||||||
in
|
in
|
||||||
finishAfterDeletingBuffer
|
finishAfterDeletingBuffer
|
||||||
(app, 0, buffer, searchList, time, initialMsg)
|
(app, 0, buffer, searchList, time, initialMsg)
|
||||||
@@ -328,9 +329,14 @@ struct
|
|||||||
(* if we deleted all text in the buffer,
|
(* if we deleted all text in the buffer,
|
||||||
* then make sure that we append a newline at the end
|
* then make sure that we append a newline at the end
|
||||||
* so that the buffer contains at least one character.
|
* so that the buffer contains at least one character.
|
||||||
* todo: incrementally update searchList based on insertion *)
|
* *)
|
||||||
val buffer =
|
val (buffer, searchList) =
|
||||||
if #textLength buffer = 0 then LineGap.append ("\n", buffer) else buffer
|
if #textLength buffer = 0 then
|
||||||
|
let val buffer = LineGap.append ("\n", buffer)
|
||||||
|
in SearchList.build (buffer, dfa)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
(buffer, searchList)
|
||||||
in
|
in
|
||||||
if low >= #textLength buffer - 1 andalso #textLength buffer > 0 then
|
if low >= #textLength buffer - 1 andalso #textLength buffer > 0 then
|
||||||
(* edge case:
|
(* edge case:
|
||||||
@@ -636,10 +642,13 @@ struct
|
|||||||
val (buffer, searchList) = SearchList.deleteBufferAndSearchList
|
val (buffer, searchList) = SearchList.deleteBufferAndSearchList
|
||||||
(lineIdx, length, buffer, searchList, dfa)
|
(lineIdx, length, buffer, searchList, dfa)
|
||||||
|
|
||||||
val buffer =
|
val (buffer, searchList) =
|
||||||
(* todo: incrementally rebuild searchList if we are appending *)
|
if #textLength buffer = 0 then
|
||||||
if #textLength buffer = 0 then LineGap.append ("\n", buffer)
|
let val buffer = LineGap.fromString "\n"
|
||||||
else buffer
|
in SearchList.build (buffer, dfa)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
(buffer, searchList)
|
||||||
|
|
||||||
(* since we deleted from the last line,
|
(* since we deleted from the last line,
|
||||||
* we want to place the cursor at the first column
|
* we want to place the cursor at the first column
|
||||||
@@ -673,10 +682,13 @@ struct
|
|||||||
val (buffer, searchList) = SearchList.deleteBufferAndSearchList
|
val (buffer, searchList) = SearchList.deleteBufferAndSearchList
|
||||||
(lineIdx, length, buffer, searchList, dfa)
|
(lineIdx, length, buffer, searchList, dfa)
|
||||||
|
|
||||||
val buffer =
|
val (buffer, searchList) =
|
||||||
(* todo: incrementally rebuild searchList if we are appending *)
|
if #textLength buffer = 0 then
|
||||||
if #textLength buffer = 0 then LineGap.append ("\n", buffer)
|
let val buffer = LineGap.fromString "\n"
|
||||||
else buffer
|
in SearchList.build (buffer, dfa)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
(buffer, searchList)
|
||||||
in
|
in
|
||||||
finishAfterDeletingBuffer
|
finishAfterDeletingBuffer
|
||||||
(app, newCursorIdx, buffer, searchList, time, initialMsg)
|
(app, newCursorIdx, buffer, searchList, time, initialMsg)
|
||||||
@@ -823,11 +835,13 @@ struct
|
|||||||
val (buffer, searchList) = SearchList.deleteBufferAndSearchList
|
val (buffer, searchList) = SearchList.deleteBufferAndSearchList
|
||||||
(cursorIdx, length, buffer, searchList, dfa)
|
(cursorIdx, length, buffer, searchList, dfa)
|
||||||
|
|
||||||
val buffer =
|
val (buffer, searchList) =
|
||||||
(* todo: rebuild searchList if
|
if #textLength buffer = 0 then
|
||||||
* we are creating new buffer from string *)
|
let val buffer = LineGap.fromString "\n"
|
||||||
if #textLength buffer = 0 then LineGap.fromString "\n"
|
in SearchList.build (buffer, dfa)
|
||||||
else buffer
|
end
|
||||||
|
else
|
||||||
|
(buffer, searchList)
|
||||||
|
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
val cursorIdx =
|
val cursorIdx =
|
||||||
@@ -900,10 +914,13 @@ struct
|
|||||||
val (buffer, searchList) = SearchList.deleteBufferAndSearchList
|
val (buffer, searchList) = SearchList.deleteBufferAndSearchList
|
||||||
(0, cursorIdx, buffer, searchList, dfa)
|
(0, cursorIdx, buffer, searchList, dfa)
|
||||||
|
|
||||||
val buffer =
|
val (buffer, searchList) =
|
||||||
(* todo: adjust searchList if we call SearchList.fromString *)
|
if #textLength buffer = 0 then
|
||||||
if #textLength buffer = 0 then LineGap.fromString "\n"
|
let val buffer = LineGap.fromString "\n"
|
||||||
else buffer
|
in SearchList.build (buffer, dfa)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
(buffer, searchList)
|
||||||
|
|
||||||
val buffer = LineGap.goToIdx (cursorIdx - 1111, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx - 1111, buffer)
|
||||||
val (buffer, searchList) = SearchList.build (buffer, dfa)
|
val (buffer, searchList) = SearchList.build (buffer, dfa)
|
||||||
@@ -955,11 +972,13 @@ struct
|
|||||||
val (buffer, searchList) = SearchList.deleteBufferAndSearchList
|
val (buffer, searchList) = SearchList.deleteBufferAndSearchList
|
||||||
(startOfLineIdx, length, buffer, searchList, dfa)
|
(startOfLineIdx, length, buffer, searchList, dfa)
|
||||||
|
|
||||||
val buffer =
|
val (buffer, searchList) =
|
||||||
(* todo: if we are creating a new buffer from string,
|
if #textLength buffer = 0 then
|
||||||
* then make sure we update the searchList for it too *)
|
let val buffer = LineGap.fromString "\n"
|
||||||
if #textLength buffer = 0 then LineGap.fromString "\n"
|
in SearchList.build (buffer, dfa)
|
||||||
else buffer
|
end
|
||||||
|
else
|
||||||
|
(buffer, searchList)
|
||||||
|
|
||||||
val newLineEndIdx = Int.max (startOfLineIdx - 1, 0)
|
val newLineEndIdx = Int.max (startOfLineIdx - 1, 0)
|
||||||
val buffer = LineGap.goToIdx (newLineEndIdx, buffer)
|
val buffer = LineGap.goToIdx (newLineEndIdx, buffer)
|
||||||
|
|||||||
Reference in New Issue
Block a user