From 05e3f3e2db28421fedcede9737b4e1acbc09f866 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Fri, 19 Jul 2024 19:57:57 +0100 Subject: [PATCH] amend a bug to do wth building wrong string output in line_gap.sml --- src/line_gap.sml | 26 +++++++++++++++++++++----- tests/compare_to_rope.sml | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/line_gap.sml b/src/line_gap.sml index 0a832c0..065b9ee 100644 --- a/src/line_gap.sml +++ b/src/line_gap.sml @@ -1084,11 +1084,18 @@ struct let (* Delete part of string. *) val newStrStart = finish - moveIdx + val _ = println + ("old len = " ^ Int.toString (String.size rightStringsHd)) + val _ = println + ("new len = " + ^ Int.toString (String.size rightStringsHd - newStrStart)) val newStr = String.substring ( rightStringsHd , newStrStart , String.size rightStringsHd - newStrStart ) + val _ = println + ("actual len = " ^ Int.toString (String.size newStr)) (* Delete from line vector if we need to. *) val newLines = @@ -1436,14 +1443,15 @@ struct * will delete rightwards if it needs to, or else terminates. *) let val _ = println "1373" + val _ = println ("1444 = " ^ Int.toString (finish - start)) in deleteRightFromHere - ( curIdx - , curLine - , curIdx + ( nextIdx + , curLine + Vector.length rightLinesHd + , nextIdx , finish - , leftStrings - , leftLines + , rightStringsHd :: leftStrings + , rightLinesHd :: leftLines , rightStringsTl , rightLinesTl ) @@ -1992,6 +2000,14 @@ struct if length > 0 then let val _ = println "deleting..." + val _ = println (String.concat + [ "length = " + , Int.toString length + , "| start = " + , Int.toString start + , "| start + length = " + , Int.toString (start + length) + ]) in del ( start diff --git a/tests/compare_to_rope.sml b/tests/compare_to_rope.sml index d5bcf8e..56267f2 100644 --- a/tests/compare_to_rope.sml +++ b/tests/compare_to_rope.sml @@ -4,7 +4,7 @@ struct Vector.foldli (fn (idx, (pos, delNum, insStr), (rope, gapBuffer)) => let - val _ = print ("idx: " ^ Int.toString idx ^ "\n") + val _ = print ("txn number: " ^ Int.toString idx ^ "\n") val oldRope = rope val strSize = String.size insStr