diff -r 268408ec0be5 -r 88062aff617b Tools__BreakpointService.st --- a/Tools__BreakpointService.st Fri Aug 23 22:01:33 2019 +0200 +++ b/Tools__BreakpointService.st Fri Aug 23 22:07:16 2019 +0200 @@ -107,13 +107,28 @@ breakpoints isEmptyOrNil ifTrue:[^ nil]. pos := textView characterPositionOfLine:line col:1. - ^ breakpoints - detect:[:each | each position = pos ] - ifNone:[ - breakpoints - detect:[:each | each line == line and:[each position isNil ]] - ifNone:[ nil ] - ] + "/ breakpoints are sorted by line + "/ (or even by position within a line, but those are currently not supported by the GUI). + "/ We can stop searching early + breakpoints do:[:each | + |bpLine| + + bpLine := each line. + bpLine == line ifTrue:[^ each]. + bpLine > line ifTrue:[^ nil]. + ]. + ^ nil. + +"/ ^ breakpoints +"/ detect:[:each | each position = pos ] +"/ ifNone:[ +"/ breakpoints +"/ detect:[:each | each line == line and:[each position isNil ]] +"/ ifNone:[ +"/ self halt. +"/ nil +"/ ] +"/ ] "Modified: / 17-06-2011 / 13:59:17 / Jan Vrany " "Modified: / 16-08-2017 / 08:29:51 / cg" @@ -504,26 +519,17 @@ fixupBreakpointPositions "computes the character positions of all line breakpoints" - breakpoints notEmptyOrNil ifTrue:[ + breakpoints notEmptyOrNil ifTrue:[ + "/ self assert:(breakpoints contains:[:b | b line < 0]) not. breakpoints do:[:each | | pos | pos := textView characterPositionOfLine:(each line) col:1. each position:pos line:(each line). ]. + "/ self assert:(breakpoints contains:[:b | b line < 0]) not. breakpoints := breakpoints select:[:b | b line >= 0]. - breakpoints asOrderedCollection - sort:[:a :b| - |pA pB| - - pA := a position. - pB := b position. - (pA notNil and:[pB notNil]) ifTrue:[ - pA < pB - ] ifFalse:[ - a line < b line - ] - ]. + self sortBreakpoints. ]. "Created: / 08-05-2014 / 14:02:25 / Jan Vrany " @@ -532,12 +538,14 @@ ! moveBreakpointsAfterLine:line by: delta + "/ self assert:(breakpoints contains:[:b | b line < 0]) not. breakpoints do:[:bpnt| bpnt line >= line ifTrue:[ "/ Note that position will be fixed up in BreakpointService>>breakpoints bpnt position:nil line:(bpnt line + delta). ] ]. + "/ self assert:(breakpoints contains:[:b | b line < 0]) not. breakpoints := breakpoints reject:[:bpnt | bpnt line <= 0]. "/gutterView redrawLinesFrom: line. @@ -638,7 +646,7 @@ "/ this assertion occasionally failed - and lead to wrong breakpoint handling in the compiler. "/ for now, as a q&d hack, sort them to make sure. "/ self assert:(breakpoints isSortedBy:[:a :b |a position <= b position]). - breakpoints sort:[:a :b |a position <= b position]. + self sortBreakpoints. "/ must update breakpoints BEFORE the following, because it leads to a change "/ notification, which may clear the breakpoints collection!! @@ -654,6 +662,26 @@ ]. "Created: / 20-02-2019 / 17:26:24 / Claus Gittinger" +! + +sortBreakpoints + "breakpoints are sorted by line + (or even by position within a line, but those are currently not supported by the GUI)" + + breakpoints := breakpoints + asOrderedCollection + sort:[:a :b| + |pA pB| + + pA := a position. + pB := b position. + (pA notNil and:[pB notNil]) ifTrue:[ + "/ self assert:(pA <= pB) = (a line <= b line). + pA < pB + ] ifFalse:[ + a line < b line + ] + ]. ! ! !BreakpointService methodsFor:'queries'!