#OTHER by cg
class: TextView
fix: selecting the search result of a pattern search
added: #showMatch:isMatch:atLine:col:endCol:
changed:
#searchBwdUsingSpec:ifAbsent:
#searchFwdUsingSpec:startingAtLine:col:ifAbsent:
#showMatch:atLine:col:
#showMatch:isMatch:atLine:col:
--- a/TextView.st Sat May 07 15:48:27 2016 +0200
+++ b/TextView.st Sat May 07 15:48:54 2016 +0200
@@ -3647,10 +3647,12 @@
startCol := pos x.
self
- searchBackwardUsingSpec:searchSpec
- startingAtLine:startLine col:startCol
- ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col]
- ifAbsent:aBlock
+ searchBackwardUsingSpec:searchSpec
+ startingAtLine:startLine col:startCol
+ ifFound:[:line :col :endColOrNil|
+ self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col endCol:endColOrNil
+ ]
+ ifAbsent:aBlock
!
searchForAndSelectMatchingParenthesisFromLine:startLine col:startCol
@@ -4390,8 +4392,8 @@
self
searchForwardUsingSpec:searchSpec
startingAtLine:startLine col:startCol
- ifFound:[:line :col |
- self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col
+ ifFound:[:line :col :endColOrNil|
+ self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col endCol:endColOrNil
]
ifAbsent:aBlock
!
@@ -4493,33 +4495,43 @@
!
showMatch:pattern atLine:line col:col
+ <resource: #obsolete>
"after a search, highlight the matched pattern.
The code below needs a rewrite to take care of match-characters
(for now, it only highlights simple patterns and '*string*' correctly)"
- self showMatch:pattern isMatch:true atLine:line col:col
+ self showMatch:pattern isMatch:true atLine:line col:col endCol:nil
!
showMatch:pattern isMatch:isMatch atLine:line col:col
+ <resource: #obsolete>
+ "after a search, highlight the matched pattern."
+
+ self showMatch:pattern isMatch:isMatch atLine:line col:col endCol:nil
+!
+
+showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil
"after a search, highlight the matched pattern.
The code below needs a rewrite to take care of match-characters
(for now, it only highlights simple patterns and '*string*' correctly)"
- |realPattern|
-
- realPattern := pattern.
-
- isMatch ifTrue: [
- (realPattern startsWith:$*) ifTrue:[
- realPattern := realPattern copyButFirst
+ |endCol realPattern|
+
+ (endCol := encColOrNil) isNil ifTrue:[
+ "/ a hack.
+ realPattern := pattern.
+ isMatch ifTrue: [
+ (realPattern startsWith:$*) ifTrue:[
+ realPattern := realPattern copyButFirst
+ ].
+ (realPattern endsWith:$*) ifTrue:[
+ realPattern := realPattern copyButLast
+ ].
].
- (realPattern endsWith:$*) ifTrue:[
- realPattern := realPattern copyButLast
- ].
+ endCol := (col + realPattern size - 1).
].
- self selectFromLine:line col:col
- toLine:line col:(col + realPattern size - 1).
+ self selectFromLine:line col:col toLine:line col:endCol.
self makeLineVisible:line
!