From ae1772605bcb4ae03e5fc0730239f2f91e6bc345 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sun, 14 Sep 2025 10:39:51 +0100 Subject: [PATCH] in TextBuilderWithHighlight.build, check when we encounter a \n if we would be past the last line, and return the acc if so, or else continue looping --- .../text-builder-with-highlight.sml | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/fcore/text-builder/text-builder-with-highlight.sml b/fcore/text-builder/text-builder-with-highlight.sml index a2183f2..a1dc27a 100644 --- a/fcore/text-builder/text-builder-with-highlight.sml +++ b/fcore/text-builder/text-builder-with-highlight.sml @@ -236,23 +236,27 @@ struct Utils.makeCursor (posX, posY, env) :: acc else acc + val nextLineNumber = lineNumber + 1 in - build - ( pos + 1 - , str - , stl - , line - , ltl - , #startX env - , posY + TC.ySpace - , 0 - , lineNumber + 1 - , absIdx + 1 - , cursorIdx - , env - , acc - , searchPos - ) + if nextLineNumber > #lastLineNumber env then + acc + else + build + ( pos + 1 + , str + , stl + , line + , ltl + , #startX env + , posY + TC.ySpace + , 0 + , nextLineNumber + , absIdx + 1 + , cursorIdx + , env + , acc + , searchPos + ) end | chr => if column < #scrollColumnStart env then