care for empty selection in comment/uncomment rel3-1-2
authorClaus Gittinger <cg@exept.de>
Tue, 12 Nov 1996 11:33:36 +0100
changeset 880 a75287739271
parent 879 5bb93a1651cd
child 881 76f7f4b3d4a9
care for empty selection in comment/uncomment
CodeView.st
--- a/CodeView.st	Mon Nov 11 11:28:09 1996 +0100
+++ b/CodeView.st	Tue Nov 12 11:33:36 1996 +0100
@@ -153,16 +153,20 @@
 
     |e|
 
-    (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
-	self commentFrom:selectionStartLine to:selectionEndLine-1
-    ] ifFalse:[
-	self insert:$" atLine:selectionStartLine col:selectionStartCol.
-	e := selectionEndCol + 1.
-	selectionStartLine == selectionEndLine ifTrue:[e := e + 1].
-	self insert:$" atLine:selectionEndLine col:e.
-	self selectFromLine:selectionStartLine col:selectionStartCol
-		     toLine:selectionEndLine col:e.
+    selectionStartLine notNil ifTrue:[
+        (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
+            self commentFrom:selectionStartLine to:selectionEndLine-1
+        ] ifFalse:[
+            self insert:$" atLine:selectionStartLine col:selectionStartCol.
+            e := selectionEndCol + 1.
+            selectionStartLine == selectionEndLine ifTrue:[e := e + 1].
+            self insert:$" atLine:selectionEndLine col:e.
+            self selectFromLine:selectionStartLine col:selectionStartCol
+                         toLine:selectionEndLine col:e.
+        ]
     ]
+
+    "Modified: 12.11.1996 / 11:32:40 / cg"
 !
 
 editMenu
@@ -239,23 +243,27 @@
 
     |e|
 
-    (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
-	self uncommentFrom:selectionStartLine to:selectionEndLine-1
-    ] ifFalse:[
-	((self characterAtLine:selectionStartLine col:selectionStartCol) == $"
-	and:[(self characterAtLine:selectionEndLine col:selectionEndCol) == $"]) ifTrue:[
-	    self deleteCharAtLine:selectionEndLine col:selectionEndCol.
-	    self deleteCharAtLine:selectionStartLine col:selectionStartCol.
-	    e := selectionEndCol - 1.
-	    selectionStartLine == selectionEndLine ifTrue:[e := e - 1].
-	    self selectFromLine:selectionStartLine col:selectionStartCol
-			 toLine:selectionEndLine col:e.
-	]
+    selectionStartLine notNil ifTrue:[
+        (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
+            self uncommentFrom:selectionStartLine to:selectionEndLine-1
+        ] ifFalse:[
+            ((self characterAtLine:selectionStartLine col:selectionStartCol) == $"
+            and:[(self characterAtLine:selectionEndLine col:selectionEndCol) == $"]) ifTrue:[
+                self deleteCharAtLine:selectionEndLine col:selectionEndCol.
+                self deleteCharAtLine:selectionStartLine col:selectionStartCol.
+                e := selectionEndCol - 1.
+                selectionStartLine == selectionEndLine ifTrue:[e := e - 1].
+                self selectFromLine:selectionStartLine col:selectionStartCol
+                             toLine:selectionEndLine col:e.
+            ]
+        ]
     ]
+
+    "Modified: 12.11.1996 / 11:32:57 / cg"
 ! !
 
 !CodeView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.30 1996-04-25 16:44:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.31 1996-11-12 10:33:36 cg Exp $'
 ! !