From 8ff8ff0df1ddc6ddb74ba3cb42a868507b6997e2 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 21 Dec 2021 17:14:17 -0500 Subject: [PATCH] Make CommentBlock work when selection ends with ws at line start --- IDE/src/ui/SourceEditWidgetContent.bf | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/IDE/src/ui/SourceEditWidgetContent.bf b/IDE/src/ui/SourceEditWidgetContent.bf index 37feda6a..3b951790 100644 --- a/IDE/src/ui/SourceEditWidgetContent.bf +++ b/IDE/src/ui/SourceEditWidgetContent.bf @@ -2272,6 +2272,38 @@ namespace IDE.ui break; minPos--; } + + bool hadMaxChar = false; + int checkMaxPos = maxPos; + while (checkMaxPos > 0) + { + var c = mData.mText[checkMaxPos - 1].mChar; + if (c == '\n') + break; + if ((c != '\t') && (c != ' ')) + { + hadMaxChar = true; + break; + } + checkMaxPos--; + } + + if (!hadMaxChar) + { + checkMaxPos = maxPos; + while (checkMaxPos < mData.mTextLength) + { + var c = mData.mText[checkMaxPos].mChar; + if (c == '\n') + break; + if ((c != '\t') && (c != ' ')) + { + maxPos = checkMaxPos + 1; + break; + } + checkMaxPos++; + } + } int wantLineCol = -1; int lineStartCol = 0;