diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 8ae42ef19..98885af57 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -3771,7 +3771,10 @@ void Notepad_plus::maintainIndentation(wchar_t ch) // 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) + auto posColon = _pEditView->execute(SCI_SEARCHINTARGET, strlen(colonExpr), reinterpret_cast(colonExpr)); + + // when colon found, additionally check that it is not in a comment, inside a string, etc. + if ((posColon >= 0) && (_pEditView->execute(SCI_GETSTYLEINDEXAT, posColon) == SCE_P_OPERATOR)) { _pEditView->setLineIndent(curLine, indentAmountPrevLine + tabWidth); }