[FIX] shift-CR off by one
Henrik Gedenryd
Henrik.Gedenryd at lucs.lu.se
Tue Oct 10 08:38:12 UTC 2000
"Change Set: shiftCrOffBy1-hg
Date: 9 October 2000
Author: Henrik Gedenryd
If you do shift-cr with the cursor at the end of the edited text (as
regularly when typing a new method), you get an error. A fix for a
long-standing off-by-one bug."
Applies to both 2.8 and 2.9
-------------- next part --------------
'From Squeak2.9alpha of 13 June 2000 [latest update: #2657] on 9 October 2000 at 6:15:02 pm'!
"Change Set: shiftCrOffBy1-hg
Date: 9 October 2000
Author: Henrik Gedenryd
If you do shift-cr with the cursor at the end of the edited text (as regularly when typing a new method), you get an error. A fix for a long-standing off-by-one bug."!
!ParagraphEditor methodsFor: 'typing/selecting keys' stamp: 'hg 10/6/2000 18:51'!
crWithIndent: characterStream
"Replace the current text selection with CR followed by as many tabs
as on the current line (+/- bracket count) -- initiated by Shift-Return."
| char s i tabCount |
sensor keyboard. "flush character"
s _ paragraph string.
i _ stopBlock stringIndex.
tabCount _ 0.
[(i _ i-1) > 0 and: [(char _ s at: i) ~= Character cr]]
whileTrue: "Count tabs and brackets (but not a leading bracket)"
[(char = Character tab and: [i < s size and: [(s at: i+1) ~= $[ ]]) ifTrue: [tabCount _ tabCount + 1].
char = $[ ifTrue: [tabCount _ tabCount + 1].
char = $] ifTrue: [tabCount _ tabCount - 1]].
characterStream crtab: tabCount. "Now inject CR with tabCount tabs"
^ false! !
More information about the Squeak-dev
mailing list
|