#BUGFIX by cg
authorClaus Gittinger <cg@exept.de>
Sat, 29 Jun 2019 17:40:15 +0200
changeset 6620 d1af1ea90691
parent 6619 e042a2f30428
child 6621 a1a9e33d6daf
#BUGFIX by cg class: EditTextView changed: #handleReturnPressed fix in autoindent
EditTextView.st
--- a/EditTextView.st	Fri Jun 28 09:12:15 2019 +0200
+++ b/EditTextView.st	Sat Jun 29 17:40:15 2019 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
               All Rights Reserved
@@ -6084,6 +6082,7 @@
     leftPart := ((self listAt:cursorLine to:cursorCol-1) ? '') string.
     rightPart := ((self listAt:cursorLine from:cursorCol) ? '') string.
     self insertCharAtCursor:(Character cr).
+    self autoIndent ifFalse:[^ self].
 
     endsWithOpeningBracket := startsWithClosingBracket := [:line | false].
     (language := self editedLanguage) notNil ifTrue:[
@@ -6098,55 +6097,51 @@
             ].
     ]. 
     
-    self autoIndent ifTrue:[
-        (rightPart isEmpty and:[cursorCol ~~ 1]) ifTrue:[
-            "/ nothing to do.
-        ] ifFalse:[
-            i := self leftIndentForLine:cursorLine. 
-            
-            leftPart := leftPart withoutSeparators.
-            rightPart := rightPart withoutSeparators.
-            oldIndent := self leftIndentOfLine:cursorLine.
-
-            (self listAt:cursorLine) isEmptyOrNil ifTrue:[
-                (endsWithOpeningBracket value:leftPart) ifTrue:[
-                    newIndent := i.  "/ leftIndentForLine already adjusted the value if ending in an opening bracket
-                ] ifFalse:[
-                    (false "(left endsWith:']')" or:[(startsWithClosingBracket value:rightPart)]) ifTrue:[
-                        newIndent := (self prevTabBefore:i)-1.
-                    ] ifFalse:[
-                        newIndent := i.  "/ leftIndentForLine returns the previous line's indent
-                    ]
-                ].
+    (rightPart isEmpty and:[cursorCol ~~ 1]) ifTrue:[
+        "/ nothing to do.
+    ] ifFalse:[
+        i := self leftIndentForLine:cursorLine. 
+
+        leftPart := leftPart withoutSeparators.
+        rightPart := rightPart withoutSeparators.
+        oldIndent := self leftIndentOfLine:cursorLine.
+
+        rightPart isEmptyOrNil ifTrue:[
+            (endsWithOpeningBracket value:leftPart) ifTrue:[
+                newIndent := i.  "/ leftIndentForLine already adjusted the value if ending in an opening bracket
             ] ifFalse:[
-                (endsWithOpeningBracket value:leftPart) ifTrue:[
-                    rightPart notEmptyOrNil ifTrue:[
-                        newIndent := (self nextTabAfter:i+1)-1.
-                    ]
+                (false "(left endsWith:']')" or:[(startsWithClosingBracket value:rightPart)]) ifTrue:[
+                    newIndent := (self prevTabBefore:i)-1.
                 ] ifFalse:[
-                    (startsWithClosingBracket value:rightPart) ifTrue:[
-                        leftPart notEmptyOrNil ifTrue:[
-                            newIndent := (self prevTabBefore:i)-1.
-                        ]    
-                    ] ifFalse:[
-                        newIndent := i
+                    newIndent := i.  "/ leftIndentForLine returns the previous line's indent
+                ]
+            ].
+        ] ifFalse:[
+            (endsWithOpeningBracket value:leftPart) ifTrue:[
+                newIndent := i.
+            ] ifFalse:[
+                (startsWithClosingBracket value:rightPart) ifTrue:[
+                    leftPart notEmptyOrNil ifTrue:[
+                        newIndent := (self prevTabBefore:i)-1.
                     ]    
+                ] ifFalse:[
+                    newIndent := i
                 ]    
-            ].        
-        ].
-        newIndent notNil ifTrue:[
-            self indentFromLine:cursorLine toLine:cursorLine by:(newIndent-oldIndent).
-            self st80EditMode ifTrue:[
-                (self listAt:cursorLine) size < newIndent ifTrue:[
-                    self insertStringAtCursor:(String new:((newIndent-oldIndent) max:0)).
-                ].
+            ]    
+        ].        
+    ].
+    newIndent notNil ifTrue:[
+        self indentFromLine:cursorLine toLine:cursorLine by:(newIndent-oldIndent).
+        self st80EditMode ifTrue:[
+            (self listAt:cursorLine) size < newIndent ifTrue:[
+                self insertStringAtCursor:(String new:((newIndent-oldIndent) max:0)).
             ].
-            self cursorCol:(newIndent+1 max:1)
-        ]
+        ].
+        self cursorCol:(newIndent+1 max:1)
     ].
 
     "Created: / 26-06-2019 / 21:57:50 / Claus Gittinger"
-    "Modified: / 26-06-2019 / 23:17:45 / Claus Gittinger"
+    "Modified: / 29-06-2019 / 17:38:45 / Claus Gittinger"
 !
 
 keyPress:key x:x y:y