From 09fe611efbcdc9031d66d990fac55bb81777f09c Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sun, 14 Sep 2025 15:48:26 +0100 Subject: [PATCH] fix tracking of textLength and lineLength fields, which were previously buggy in only one delete branch; the current commit fixes that branch and verifies the tests pass --- src/line_gap.sml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/line_gap.sml b/src/line_gap.sml index fe1e00c..d915924 100644 --- a/src/line_gap.sml +++ b/src/line_gap.sml @@ -1584,9 +1584,16 @@ struct else Vector.fromList [] - val newTextLength = String.size sub1 + String.size sub1 - val newLineLength = + val newNodeTextLength = String.size sub1 + String.size sub2 + val textLengthDifference = + oldNodeTextLength - newNodeTextLength + val newTextLength = textLength - textLengthDifference + + val newNodeLineLength = Vector.length sub1Lines + Vector.length sub2Lines + val lineLengthDifference = + oldNodeLineLength - newNodeLineLength + val newLineLength = lineLength - lineLengthDifference in { idx = curIdx + String.size sub1 , textLength = newTextLength