From b54b8ee54f085129a2c4e04f0887b74a6204af3d Mon Sep 17 00:00:00 2001 From: Don HO Date: Thu, 12 Nov 2020 15:14:51 +0100 Subject: [PATCH] Improve indent guidelines on non-brace control block languages Fix #9137 --- PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp | 6 ++---- PowerEditor/src/ScitillaComponent/ScintillaEditView.h | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index d1957de09..98ef5fe25 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -1788,8 +1788,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc) const auto currentIndentMode = execute(SCI_GETINDENTATIONGUIDES); // Python like indentation, excludes lexers (Nim, VB, YAML, etc.) // that includes tailing empty or whitespace only lines in folding block. - const bool pythonLike = (typeDoc == L_PYTHON || typeDoc == L_COFFEESCRIPT || typeDoc == L_HASKELL); - const int docIndentMode = pythonLike ? SC_IV_LOOKFORWARD : SC_IV_LOOKBOTH; + const int docIndentMode = isPythonStyleIndentation(typeDoc) ? SC_IV_LOOKFORWARD : SC_IV_LOOKBOTH; if (currentIndentMode != docIndentMode) execute(SCI_SETINDENTATIONGUIDES, docIndentMode); } @@ -2683,8 +2682,7 @@ void ScintillaEditView::performGlobalStyles() void ScintillaEditView::showIndentGuideLine(bool willBeShowed) { auto typeDoc = _currentBuffer->getLangType(); - const bool pythonLike = (typeDoc == L_PYTHON || typeDoc == L_COFFEESCRIPT || typeDoc == L_HASKELL); - const int docIndentMode = pythonLike ? SC_IV_LOOKFORWARD : SC_IV_LOOKBOTH; + const int docIndentMode = isPythonStyleIndentation(typeDoc) ? SC_IV_LOOKFORWARD : SC_IV_LOOKBOTH; execute(SCI_SETINDENTATIONGUIDES, willBeShowed ? docIndentMode : SC_IV_NONE); } diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index bc76f4527..1c2035742 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -594,6 +594,12 @@ public: return false; }; + bool isPythonStyleIndentation(LangType typeDoc) const{ + return (typeDoc == L_PYTHON || typeDoc == L_COFFEESCRIPT || typeDoc == L_HASKELL ||\ + typeDoc == L_C || typeDoc == L_CPP || typeDoc == L_OBJC || typeDoc == L_CS || typeDoc == L_JAVA ||\ + typeDoc == L_PHP || typeDoc == L_JS || typeDoc == L_JAVASCRIPT || typeDoc == L_MAKEFILE || typeDoc == L_ASN1); + }; + void defineDocType(LangType typeDoc); //setup stylers for active document void addCustomWordChars();