--- a/TextView.st Tue Oct 16 13:44:31 2018 +0200
+++ b/TextView.st Thu Oct 18 18:45:53 2018 +0200
@@ -1629,11 +1629,11 @@
(must de before doing the ST80 stuff below)
"
((sel := self selection) size == 1
- and:[(sel := sel at:1) size == 1]) ifTrue:[
+ and:[(sel := sel at:1) size == 1]) ifTrue:[
ch := sel at:1.
((self isOpeningParenthesis:ch)
- or:[ (self isClosingParenthesis:ch) ]) ifTrue:[
+ or:[self isClosingParenthesis:ch]) ifTrue:[
self
searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol
ifFound:[:line :col |
@@ -1798,6 +1798,7 @@
"Created: / 11-09-1997 / 04:12:55 / cg"
"Modified: / 14-06-2011 / 14:04:59 / cg"
"Modified (format): / 13-02-2017 / 20:32:08 / cg"
+ "Modified (format): / 18-10-2018 / 17:06:07 / Stefan Vogel"
!
extendSelectionToX:x y:y
@@ -4476,10 +4477,10 @@
endCol "{ Class: SmallInteger }"
runCol "{ Class: SmallInteger }"
cc prevCC nextCC incSet decSet
- nesting "{ Class: SmallInteger }"
+ nesting
maxLine "{ Class: SmallInteger }"
ign skip anySet
- eol1 eol2|
+ eol1 eol2 inLineComment idx|
self assert:(openingCharacters size == closingCharacters size).
@@ -4494,6 +4495,10 @@
direction := (i <= openingCharacters size) ifTrue:[#fwd] ifFalse:[#bwd].
closingChar := (closingCharacters , openingCharacters) at:i.
+ "nesting is a Stack containing {expected char . line number of found char} tuples"
+ nesting := Stack new.
+ nesting push:{closingChar. startLine}.
+
eol1 := eolCommentSequence at:1 ifAbsent:nil.
eol2 := eolCommentSequence at:2 ifAbsent:nil.
@@ -4512,15 +4517,14 @@
anySet addAll:incSet; addAll:decSet; addAll:ignoreSet.
anySet := (anySet select:[:c | c isCharacter]) asString.
- nesting := 1.
ignoring := false.
lineString := list at:line.
maxLine := list size.
col := col + delta.
- [nesting ~~ 0] whileTrue:[
- (lineString notNil
- and:[lineString includesAny:anySet]) ifTrue:[
+ [nesting notEmpty] whileTrue:[
+ (lineString notNil and:[lineString includesAny:anySet]) ifTrue:[
+ inLineComment := false.
direction == #fwd ifTrue:[
endCol := lineString size.
] ifFalse:[
@@ -4529,7 +4533,6 @@
col to:endCol by:delta do:[:rCol |
runCol := rCol.
-
cc := lineString at:runCol.
runCol < lineString size ifTrue:[
nextCC := lineString at:runCol+1
@@ -4544,29 +4547,33 @@
ign := skip := false.
- "/ check for comments.
-
- ((cc == eol1 and:[nextCC == eol2])
- or:[prevCC == $$ ]) ifTrue:[
- "/ do nothing
-
+ (cc == eol1 and:[nextCC == eol2]) ifTrue:[
+ "/ check for comments, do not search for a matching '"' in a "/ comment.
+ inLineComment := skip := true.
+ [nesting top second = line] whileTrue:[
+ "while doing backward searching we have found a line comment
+ containing a opening/closing char"
+ nesting pop.
+ ].
+ ] ifFalse:[prevCC == $$ ifTrue:[
+ "/ do not search for a matching peer for $( or $[...
skip := true.
] ifFalse:[
- ignoreSet do:[:ignore |
- ignore == cc ifTrue:[
+ ignoreSet do:[:eachCharToIgnore |
+ eachCharToIgnore == cc ifTrue:[
ign := true
] ifFalse:[
- ignore isString ifTrue:[
- cc == (ignore at:2) ifTrue:[
+ eachCharToIgnore isString ifTrue:[
+ cc == (eachCharToIgnore at:2) ifTrue:[
runCol > 1 ifTrue:[
- (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[
+ (lineString at:(runCol-1)) == (eachCharToIgnore at:1) ifTrue:[
skip := true
]
]
] ifFalse:[
- cc == (ignore at:1) ifTrue:[
+ cc == (eachCharToIgnore at:1) ifTrue:[
runCol < lineString size ifTrue:[
- (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[
+ (lineString at:(runCol+1)) == (eachCharToIgnore at:2) ifTrue:[
skip := true
]
]
@@ -4575,33 +4582,39 @@
]
]
]
- ].
-
- ign ifTrue:[
- ignoring := ignoring not
+ ]].
+
+ (inLineComment not & ign) ifTrue:[
+ "/ íf in a line comment, single ' and " may occur.
+ "/ ignoring means, that we ignore non-matching peers.
+ ignoring ifTrue:[
+ nesting pop first ~= cc ifTrue:[
+ ^ failBlock value.
+ ].
+ ignoring := false.
+ ] ifFalse:[
+ nesting push:{cc . line}.
+ ignoring := true.
+ ].
].
- ignoring ifFalse:[
- skip ifFalse:[
- (incSet includes:cc) ifTrue:[
- nesting := nesting + 1
- ] ifFalse:[
- (decSet includes:cc) ifTrue:[
- nesting := nesting - 1
- ]
+ (ignoring | skip | inLineComment) ifFalse:[
+ ((idx := incSet indexOf:cc) ~~0) ifTrue:[
+ nesting push:{(decSet at:idx). line}.
+ ] ifFalse:[
+ (decSet includes:cc) ifTrue:[
+ nesting pop first ~= cc ifTrue:[
+ ^ failBlock value.
+ ].
]
]
].
- nesting == 0 ifTrue:[
- "check if legal"
+ nesting isEmpty ifTrue:[
skip ifFalse:[
- cc == closingChar ifFalse:[
- ^ failBlock value
- ].
^ foundBlock value:line value:runCol.
]
- ]
+ ].
].
].
line := line + delta.
@@ -4619,6 +4632,7 @@
"Modified: / 15-10-1996 / 12:22:30 / cg"
"Modified (comment): / 13-02-2017 / 20:32:43 / cg"
+ "Modified (format): / 18-10-2018 / 18:42:55 / Stefan Vogel"
!
searchFwd