From 48a2b30c136859951936dd9b9b7f4119176cd30d Mon Sep 17 00:00:00 2001 From: Alan Kilborn Date: Fri, 9 Aug 2024 08:22:53 -0400 Subject: [PATCH] Fix Python smart indent wrongly when comment line ends in colon Fix #15528, close #15529 --- PowerEditor/src/Notepad_plus.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index eb1d0910e4f..8ae42ef1975 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -3768,7 +3768,8 @@ void Notepad_plus::maintainIndentation(wchar_t ch) auto endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, prevLine); _pEditView->execute(SCI_SETTARGETRANGE, startPos, endPos); - const char colonExpr[] = ":[ \t]*(#|$)"; // colon optionally followed by only whitespace and/or start-of-comment + // colon optionally followed by only whitespace and/or start-of-comment, but NOT on a line that is already a comment + const char colonExpr[] = "^[^#]*\\K:[ \t]*(#|$)"; if (_pEditView->execute(SCI_SEARCHINTARGET, strlen(colonExpr), reinterpret_cast(colonExpr)) >= 0) {