Skip to content

Commit

Permalink
Fix redundant end keyword for current code block after auto indent te…
Browse files Browse the repository at this point in the history
…xt, issue #218.
  • Loading branch information
zufuliu committed Jun 23, 2020
1 parent 5a6ec94 commit ea8bf7d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/EditAutoC.c
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,7 @@ const char *EditKeywordIndent(const char *head, int *indent) {
case SCLEX_MATLAB:
if (!strcmp(word, "function")) {
*indent = 1;
// 'end' is optional
} else if (!strcmp(word, "if") || !strcmp(word, "for") || !strcmp(word, "while") || !strcmp(word, "switch") || !strcmp(word, "try")) {
*indent = 2;
if (pLexCurrent->rid == NP2LEX_OCTAVE || np2LexLangIndex == IDM_LEXER_OCTAVE) {
Expand Down Expand Up @@ -1974,6 +1975,13 @@ void EditAutoIndent(void) {
iIndentLen += 1;
}

if (indent == 2 && endPart) {
const int level = SciCall_GetFoldLevel(iCurLine);
if (!(level & SC_FOLDLEVELHEADERFLAG)) {
indent = 1;
}
}

Sci_Position iIndentPos = iCurPos;
if (indent) {
int pad = iIndentWidth;
Expand Down

0 comments on commit ea8bf7d

Please sign in to comment.