From 83debc292e676c7360459b9abe78d9a38a3a7245 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 15 Nov 2014 17:45:47 +0000 Subject: [PATCH] [NEW_FEATURE] Smart Indent (in progress). git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1291 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index c3b09d63..d2bb6078 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2325,11 +2325,11 @@ void Notepad_plus::maintainIndentation(TCHAR ch) // get previous char from current line int prevPos = _pEditView->execute(SCI_GETCURRENTPOS) - (eolMode == SC_EOL_CRLF ? 3 : 2); UCHAR prevChar = (UCHAR)_pEditView->execute(SCI_GETCHARAT, prevPos); + int curPos = _pEditView->execute(SCI_GETCURRENTPOS); + UCHAR nextChar = (UCHAR)_pEditView->execute(SCI_GETCHARAT, curPos); if (prevChar == '{')// && c++ java, c# js php) { - int curPos = _pEditView->execute(SCI_GETCURRENTPOS); - UCHAR nextChar = (UCHAR)_pEditView->execute(SCI_GETCHARAT, curPos); if (nextChar == '}') { _pEditView->execute(SCI_INSERTTEXT, _pEditView->execute(SCI_GETCURRENTPOS), (LPARAM)"\r\n"); @@ -2337,6 +2337,10 @@ void Notepad_plus::maintainIndentation(TCHAR ch) } _pEditView->setLineIndent(curLine, indentAmountPrevLine + tabWidth); } + else if (nextChar == '{') + { + _pEditView->setLineIndent(curLine, indentAmountPrevLine); + } else if (isConditionExprLine(prevLine)) { _pEditView->setLineIndent(curLine, indentAmountPrevLine + tabWidth);