From 706d6d15447ba707c5d4b70e94401ddf3233ba10 Mon Sep 17 00:00:00 2001 From: Fusioon Date: Fri, 14 Mar 2025 22:38:52 +0100 Subject: [PATCH] Preserve cursor position on CommentLines --- IDE/src/ui/SourceEditWidgetContent.bf | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/IDE/src/ui/SourceEditWidgetContent.bf b/IDE/src/ui/SourceEditWidgetContent.bf index 1ca10780..8a145c72 100644 --- a/IDE/src/ui/SourceEditWidgetContent.bf +++ b/IDE/src/ui/SourceEditWidgetContent.bf @@ -3019,6 +3019,7 @@ namespace IDE.ui didLineComment = false; lineStartCol = 0; + int appendedCount = 0; for (int i = minPos; i < maxPos; i++) { var c = mData.mText[i].mChar; @@ -3056,6 +3057,8 @@ namespace IDE.ui InsertAtCursor(str); didLineComment = true; maxPos += str.Length; + if (i <= startTextPos + appendedCount) + appendedCount += str.Length; } } mSelection = EditSelection(minPos, maxPos); @@ -3063,7 +3066,10 @@ namespace IDE.ui if (undoBatchStart != null) mData.mUndoManager.Add(undoBatchStart.mBatchEnd); - CursorLineAndColumn = startLineAndCol; + if (appendedCount > 0) + CursorTextPos = startTextPos + appendedCount; + else + CursorLineAndColumn = startLineAndCol; if (!hadSelection) mSelection = null;