fixed search-again if cursor is at start of text, and
authorClaus Gittinger <cg@exept.de>
Sun, 26 Nov 2000 14:39:28 +0100
changeset 2323 ef201d5d0689
parent 2322 7d8f3c26a047
child 2324 98f7a9a4c50a
fixed search-again if cursor is at start of text, and nothing has been searched yet (will find very first string now)
EditTextView.st
--- a/EditTextView.st	Fri Nov 24 11:47:13 2000 +0100
+++ b/EditTextView.st	Sun Nov 26 14:39:28 2000 +0100
@@ -4834,65 +4834,68 @@
      If current selection is not last string, search forward to
      next occurence of it before repeating the last operation."
 
-    |s l c sel savedSelectStyle|
+    |s l c sel savedSelectStyle startColForSearch|
 
     lastString notNil ifTrue:[
-	s := lastString asString.
-
-	"remove final cr"
-	s := s copyWithoutLast:1.
+        s := lastString asString.
+
+        "remove final cr"
+        s := s copyWithoutLast:1.
 "/        s := s withoutSpaces.        "XXX - replacing text with spaces ..."
-	savedSelectStyle := selectStyle.
-	selectStyle := nil.
-
-	sel := self selection.
-
-	"if we are already there (after a find), ommit search"
-
-	(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
-	    undoAction := [self insertLines:lastString atLine:cursorLine col:cursorCol].
-	    l := selectionStartLine "cursorLine". 
-	    c := selectionStartCol "cursorCol".
-	    self deleteSelection.
-	    lastReplacement notNil ifTrue:[
-		self insertLines:lastReplacement asStringCollection withCR:false.
-		self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
-	    ].
-	    selectStyle := savedSelectStyle.
-	    ^ true
-	].
-
-	self searchForwardFor:s startingAtLine:cursorLine col:cursorCol 
-	    ifFound:
-		[
-		    :line :col |
-
-		    |repl|
-
-		    self selectFromLine:line col:col
-				 toLine:line col:(col + s size - 1).
-		    self makeLineVisible:line.
-		    undoAction := [self insertLines:lastString atLine:line col:col].
-
-		    self deleteSelection.
-		    lastReplacement notNil ifTrue:[
-			lastReplacement isString ifFalse:[
-			    repl := lastReplacement asString withoutSpaces
-			] ifTrue:[
-			    repl := lastReplacement withoutSpaces.
-			].
-			self insertLines:repl asStringCollection withCR:false.
-			self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
-		    ].
-		    selectStyle := savedSelectStyle.
-		    ^ true
-		] 
-	   ifAbsent:
-		[
-		    self showNotFound.
-		    selectStyle := savedSelectStyle.
-		    ^ false
-		]
+        savedSelectStyle := selectStyle.
+        selectStyle := nil.
+
+        sel := self selection.
+
+        "if we are already there (after a find), ommit search"
+
+        (sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
+            undoAction := [self insertLines:lastString atLine:cursorLine col:cursorCol].
+            l := selectionStartLine "cursorLine". 
+            c := selectionStartCol "cursorCol".
+            self deleteSelection.
+            lastReplacement notNil ifTrue:[
+                self insertLines:lastReplacement asStringCollection withCR:false.
+                self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
+            ].
+            selectStyle := savedSelectStyle.
+            ^ true
+        ].
+        startColForSearch := cursorCol.
+        sel isNil ifTrue:[
+            startColForSearch := startColForSearch - 1
+        ].
+        self searchForwardFor:s startingAtLine:cursorLine col:startColForSearch 
+            ifFound:
+                [
+                    :line :col |
+
+                    |repl|
+
+                    self selectFromLine:line col:col
+                                 toLine:line col:(col + s size - 1).
+                    self makeLineVisible:line.
+                    undoAction := [self insertLines:lastString atLine:line col:col].
+
+                    self deleteSelection.
+                    lastReplacement notNil ifTrue:[
+                        lastReplacement isString ifFalse:[
+                            repl := lastReplacement asString withoutSpaces
+                        ] ifTrue:[
+                            repl := lastReplacement withoutSpaces.
+                        ].
+                        self insertLines:repl asStringCollection withCR:false.
+                        self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
+                    ].
+                    selectStyle := savedSelectStyle.
+                    ^ true
+                ] 
+           ifAbsent:
+                [
+                    self showNotFound.
+                    selectStyle := savedSelectStyle.
+                    ^ false
+                ]
     ]
 
     "Modified: 9.10.1996 / 16:14:11 / cg"
@@ -4916,5 +4919,5 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.241 2000-11-16 16:21:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.242 2000-11-26 13:39:28 cg Exp $'
 ! !