don't deleteByDfa when buffer's length is 1, because that would mean that we would be deleting last newline in file
This commit is contained in:
@@ -227,7 +227,10 @@ struct
|
|||||||
finishAfterDeletingBuffer (app, low, buffer, time, initialMsg)
|
finishAfterDeletingBuffer (app, low, buffer, time, initialMsg)
|
||||||
end
|
end
|
||||||
|
|
||||||
fun deleteByDfa (app: app_type, count, fMove, time) =
|
fun deleteByDfa (app as {buffer, ...}: app_type, count, fMove, time) =
|
||||||
|
if #textLength buffer = 1 then
|
||||||
|
NormalFinish.clearMode app
|
||||||
|
else
|
||||||
let
|
let
|
||||||
val {buffer, cursorIdx, ...} = app
|
val {buffer, cursorIdx, ...} = app
|
||||||
|
|
||||||
@@ -235,11 +238,12 @@ struct
|
|||||||
val otherIdx = fMove (buffer, cursorIdx, count)
|
val otherIdx = fMove (buffer, cursorIdx, count)
|
||||||
in
|
in
|
||||||
if otherIdx > cursorIdx then
|
if otherIdx > cursorIdx then
|
||||||
|
if otherIdx >= #textLength buffer then
|
||||||
(* prevent us from deleting last newline
|
(* prevent us from deleting last newline
|
||||||
* to help us preserve unix-style line endings *)
|
* to help us preserve unix-style line endings *)
|
||||||
if otherIdx > #textLength buffer then
|
let val high = #textLength buffer - 1
|
||||||
finishDeleteByDfa
|
in finishDeleteByDfa (app, cursorIdx, high, buffer, time)
|
||||||
(app, cursorIdx, #textLength buffer - 1, buffer, time)
|
end
|
||||||
else
|
else
|
||||||
finishDeleteByDfa (app, cursorIdx, otherIdx, buffer, time)
|
finishDeleteByDfa (app, cursorIdx, otherIdx, buffer, time)
|
||||||
else if otherIdx < cursorIdx then
|
else if otherIdx < cursorIdx then
|
||||||
|
|||||||
Reference in New Issue
Block a user