use 'Cursor.clipIdx' in app-update.sml's 'helpDelete' and 'helpDeleteLine' functions, to ensure we never delete last line (unix text files always end with \n)

This commit is contained in:
2024-11-10 07:57:49 +00:00
parent 6e4f6b58b9
commit 5294da6780
2 changed files with 2 additions and 0 deletions

View File

@@ -370,6 +370,7 @@ struct
let let
val low = Int.min (cursorIdx, otherIdx) val low = Int.min (cursorIdx, otherIdx)
val high = Int.max (cursorIdx, otherIdx) val high = Int.max (cursorIdx, otherIdx)
val high = Cursor.clipIdx (buffer, high)
val length = high - low val length = high - low
val buffer = LineGap.delete (low, length, buffer) val buffer = LineGap.delete (low, length, buffer)
@@ -421,6 +422,7 @@ struct
fun helpDeleteLine (app: app_type, buffer, cursorIdx, otherIdx, count) = fun helpDeleteLine (app: app_type, buffer, cursorIdx, otherIdx, count) =
if count = 0 then if count = 0 then
let let
val otherIdx = Cursor.clipIdx (buffer, otherIdx)
val length = otherIdx - cursorIdx val length = otherIdx - cursorIdx
val buffer = LineGap.delete (cursorIdx, length, buffer) val buffer = LineGap.delete (cursorIdx, length, buffer)

BIN
shf

Binary file not shown.