Improve indent guidelines on non-brace control block languages

Fix #9137
This commit is contained in:
Don HO 2020-11-12 15:14:51 +01:00
parent f027e9271d
commit b54b8ee54f
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
2 changed files with 8 additions and 4 deletions

View File

@ -1788,8 +1788,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
const auto currentIndentMode = execute(SCI_GETINDENTATIONGUIDES); const auto currentIndentMode = execute(SCI_GETINDENTATIONGUIDES);
// Python like indentation, excludes lexers (Nim, VB, YAML, etc.) // Python like indentation, excludes lexers (Nim, VB, YAML, etc.)
// that includes tailing empty or whitespace only lines in folding block. // 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 = isPythonStyleIndentation(typeDoc) ? SC_IV_LOOKFORWARD : SC_IV_LOOKBOTH;
const int docIndentMode = pythonLike ? SC_IV_LOOKFORWARD : SC_IV_LOOKBOTH;
if (currentIndentMode != docIndentMode) if (currentIndentMode != docIndentMode)
execute(SCI_SETINDENTATIONGUIDES, docIndentMode); execute(SCI_SETINDENTATIONGUIDES, docIndentMode);
} }
@ -2683,8 +2682,7 @@ void ScintillaEditView::performGlobalStyles()
void ScintillaEditView::showIndentGuideLine(bool willBeShowed) void ScintillaEditView::showIndentGuideLine(bool willBeShowed)
{ {
auto typeDoc = _currentBuffer->getLangType(); auto typeDoc = _currentBuffer->getLangType();
const bool pythonLike = (typeDoc == L_PYTHON || typeDoc == L_COFFEESCRIPT || typeDoc == L_HASKELL); const int docIndentMode = isPythonStyleIndentation(typeDoc) ? SC_IV_LOOKFORWARD : SC_IV_LOOKBOTH;
const int docIndentMode = pythonLike ? SC_IV_LOOKFORWARD : SC_IV_LOOKBOTH;
execute(SCI_SETINDENTATIONGUIDES, willBeShowed ? docIndentMode : SC_IV_NONE); execute(SCI_SETINDENTATIONGUIDES, willBeShowed ? docIndentMode : SC_IV_NONE);
} }

View File

@ -594,6 +594,12 @@ public:
return false; 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 defineDocType(LangType typeDoc); //setup stylers for active document
void addCustomWordChars(); void addCustomWordChars();