Tools__CodeView2.st
changeset 12787 80349f0b6041
parent 12783 b52f85ed724e
child 12797 7428626b7c4a
--- a/Tools__CodeView2.st	Wed May 29 13:11:05 2013 +0200
+++ b/Tools__CodeView2.st	Wed May 29 13:11:30 2013 +0200
@@ -2730,18 +2730,22 @@
     the fix should be there, but someone smarter should review it
     before the patch will be pushed up"
 
-    |soCol wasOn lineNrAboveCursor ln prevTab|
+    |soCol wasOn lineNrAboveCursor ln originalLine prevTab|
 
     wasOn := self hideCursor.
+
     "JV@2012-01-06: Do not play with autoindent iff cursor is at the very beginning of the line"
-    (autoIndent and:[cursorCol ~~ 1]) ifTrue:[
+    (autoIndent 
+    and:[cursorCol ~~ 1
+    and:[ (tabPositions includes:cursorCol) 
+    ]]) ifTrue:[
         prevTab := (self prevTabBefore:cursorCol) max:1.
         "JV@2011-12-10: The list can be shorter than cursorLine,
          trailing because empty lines are not physically in the list."
         (list size >= cursorLine) ifTrue:[
-            ln := (list at:cursorLine) ? ''.
+            ln := originalLine := (list at:cursorLine) ? ''.
         ] ifFalse:[        
-            ln := ''.
+            ln := originalLine := ''.
         ].    
         ln size < prevTab ifTrue:[
             ln := ln , (String new:prevTab withAll:Character space).
@@ -2749,17 +2753,25 @@
         (ln copyTo:prevTab) isBlank ifTrue:[
             (ln copyFrom:prevTab+1) isBlank ifTrue:[
                 cursorCol > prevTab ifTrue:[
+                    self st80EditMode ifTrue:[
+                        "/ ensure that there is no conflict here: st80EditMode will
+                        "/ not allow a cursor position beyond the end of line,
+                        "/ so avoid that cursorLine:col: will force us to the beginning of the line
+                        originalLine size < prevTab ifTrue:[
+                            list at:cursorLine put:ln
+                        ]
+                    ].
                     self cursorLine:cursorLine col:prevTab.
                     wasOn ifTrue:[ self showCursor ].
                     ^  self
                 ].
             ] ifFalse:[
-                (ln copyFrom:prevTab+1 to:cursorCol-1) isBlank ifTrue:[
+                "/ (ln copyFrom:prevTab+1 to:cursorCol-1) isBlank ifTrue:[
                     self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1.
                     self cursorLine:cursorLine col:prevTab.
                     wasOn ifTrue:[ self showCursor ].
                     ^  self.
-                ]
+                "/ ]
             ]
         ].
     ].
@@ -2903,8 +2915,11 @@
 
     wasAutoIndent := autoIndent.
     autoIndent := false.
-    super insertLines:someText from:start to:end before:lineNr.
-    autoIndent := wasAutoIndent
+    [
+        super insertLines:someText from:start to:end before:lineNr.
+    ] ensure:[
+        autoIndent := wasAutoIndent
+    ]
 
     "Created: / 20-12-2011 / 15:32:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
@@ -3025,7 +3040,6 @@
     changedDiffText := true.
     diffMode := false.
     suppressNotifications := false.
-    autoIndent := UserPreferences current codeView2AutoIndent.
     reallyModifiedChannel := false asValue.
 
     self enableMotionEvents.
@@ -3435,15 +3449,15 @@
 !CodeView2 class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeView2.st,v 1.72 2013-05-28 18:52:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeView2.st,v 1.73 2013-05-29 11:11:30 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeView2.st,v 1.72 2013-05-28 18:52:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeView2.st,v 1.73 2013-05-29 11:11:30 cg Exp $'
 !
 
 version_SVN
-    ^ '$Id: Tools__CodeView2.st,v 1.72 2013-05-28 18:52:32 cg Exp $'
+    ^ '$Id: Tools__CodeView2.st,v 1.73 2013-05-29 11:11:30 cg Exp $'
 ! !