Skip to content

Commit

Permalink
Improve Python smart indent in case of string
Browse files Browse the repository at this point in the history
Improve Python smart indent by using style context.

Fix notepad-plus-plus#15534, close notepad-plus-plus#15535
  • Loading branch information
alankilborn authored and donho committed Aug 11, 2024
1 parent 48a2b30 commit ae1d09c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LPARAM>(colonExpr)) >= 0)
auto posColon = _pEditView->execute(SCI_SEARCHINTARGET, strlen(colonExpr), reinterpret_cast<LPARAM>(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);
}
Expand Down

0 comments on commit ae1d09c

Please sign in to comment.