#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Sun, 07 Jul 2019 15:14:41 +0200
changeset 6623 682c9f9e6a11
parent 6622 4521fecca373
child 6624 67b49f362dd6
#FEATURE by cg class: EditTextView changed: #handleReturnPressed better autoindent
EditTextView.st
--- a/EditTextView.st	Sun Jul 07 15:01:35 2019 +0200
+++ b/EditTextView.st	Sun Jul 07 15:14:41 2019 +0200
@@ -6049,7 +6049,7 @@
 handleReturnPressed
     "return key pressed - handle autoIndent"
     
-    |i leftPart rightPart oldIndent newIndent language 
+    |i leftPart rightPart startIndent oldIndent newIndent language 
      bracketStrings endsWithOpeningBracket startsWithClosingBracket|
     
     self isReadOnly ifTrue:[
@@ -6078,6 +6078,8 @@
         self copyAndDeleteSelection.
     ].
 
+    startIndent := self leftIndentOfLine:cursorLine.
+
     "/ split the line
     leftPart := ((self listAt:cursorLine to:cursorCol-1) ? '') string.
     rightPart := ((self listAt:cursorLine from:cursorCol) ? '') string.
@@ -6119,6 +6121,12 @@
         ] ifFalse:[
             (endsWithOpeningBracket value:leftPart) ifTrue:[
                 newIndent := i.
+                (startsWithClosingBracket value:rightPart) ifTrue:[
+                    "/ entered return inside [] - insert another empty line
+                    self insertCharAtCursor:(Character cr).
+                    self indentFromLine:cursorLine toLine:cursorLine by:startIndent.
+                    self cursorUp.
+                ]
             ] ifFalse:[
                 (startsWithClosingBracket value:rightPart) ifTrue:[
                     leftPart notEmptyOrNil ifTrue:[