diff --git a/src/moepkg/editor.nim b/src/moepkg/editor.nim index 9cf6554ad..5b2ad5e25 100644 --- a/src/moepkg/editor.nim +++ b/src/moepkg/editor.nim @@ -902,12 +902,13 @@ proc insertIndentNimForOpenBlankLine(bufStatus: var BufferStatus, if aboveLine.len > 0: # Auto indent if the current line are "var", "let", "const". - # And, if finish the current line with ':', "object" + # And, if finish the current line with ':', "object, '='" if (aboveLine.splitWhitespace == @[ru "var"] or aboveLine.splitWhitespace == @[ru "let"] or aboveLine.splitWhitespace == @[ru "const"] or - (aboveLine.len > 6 and aboveLine[aboveLine.len - 6 .. ^1] == ru "object") or - aboveLine[^1] == ru ':'): + aboveLine.splitWhitespace[^1] == (ru "object") or + aboveLine[^1] == (ru ':') or + aboveLine[^1] == (ru '=')): let count = countRepeat(aboveLine, Whitespace, 0) + tabStop oldLine = bufStatus.buffer[currentLineNum] @@ -918,8 +919,8 @@ proc insertIndentNimForOpenBlankLine(bufStatus: var BufferStatus, bufStatus.buffer[currentLineNum] = newLine # Auto indent if finish the current line with "or", "and" - elif ((aboveLine.len > 2 and aboveLine[aboveLine.len - 2 .. ^1] == ru "or") or - (aboveLine.len > 3 and aboveLine[aboveLine.len - 3 .. ^1] == ru "and")): + elif ((aboveLine.len > 2 and (aboveLine.splitWhitespace)[^1] == ru "or") or + (aboveLine.len > 3 and (aboveLine.splitWhitespace)[^1] == ru "and")): let count = countRepeat(aboveLine, Whitespace, 0) + tabStop oldLine = bufStatus.buffer[currentLineNum] @@ -948,8 +949,8 @@ proc insertIndentInPythonForOpenBlankLine(bufStatus: var BufferStatus, if aboveLine.len > 0: # if finish the current line with ':', "or", "and" in Python - if (aboveLine.len > 2 and aboveLine[aboveLine.len - 2 .. ^1] == ru "or") or - (aboveLine.len > 3 and aboveLine[aboveLine.len - 3 .. ^1] == ru "and") or + if (aboveLine.len > 2 and (aboveLine.splitWhitespace)[^1] == ru "or") or + (aboveLine.len > 3 and (aboveLine.splitWhitespace)[^1] == ru "and") or (aboveLine[^1] == ru ':'): let count = countRepeat(aboveLine, Whitespace, 0) + tabStop diff --git a/tests/teditor.nim b/tests/teditor.nim index 1439bb15f..d778d66dc 100644 --- a/tests/teditor.nim +++ b/tests/teditor.nim @@ -1649,7 +1649,7 @@ suite "Editor: Open the blank line below": # Generate test code # Enable autoindent # open the blank line below in Nim - # When the current line ends with "or", "and", ':', "object". + # When the current line ends with "or", "and", ':', "object", '='. macro openLineBelowTestCase3(keyword: string): untyped = quote do: # Generate test title @@ -1691,6 +1691,9 @@ suite "Editor: Open the blank line below": block: const keyword = "object" openLineBelowTestCase3(keyword) + block: + const keyword = "=" + openLineBelowTestCase3(keyword) # Generate test code # Enable/Disable autoindent @@ -1932,7 +1935,7 @@ suite "Editor: Open the blank line abave": # Generate test code # Enable autoindent # open the blank line above in Nim - # When the current line ends with "or", "and", ':', "object". + # When the current line ends with "or", "and", ':', "object", "=". macro openLineAboveTestCase4(keyword: string): untyped = quote do: # Generate test title @@ -1980,6 +1983,9 @@ suite "Editor: Open the blank line abave": block: const keyword = "object" openLineAboveTestCase4(keyword) + block: + const keyword = "=" + openLineAboveTestCase4(keyword) # Generate test code # Enable autoindent @@ -2027,5 +2033,3 @@ suite "Editor: Open the blank line abave": block: const keyword = ":" openLineAboveTestCase5(keyword) - -