The Inbox: Morphic-cmm.1613.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Morphic-cmm.1613.mcz

commits-2
Chris Muller uploaded a new version of Morphic to project The Inbox:
http://source.squeak.org/inbox/Morphic-cmm.1613.mcz

==================== Summary ====================

Name: Morphic-cmm.1613
Author: cmm
Time: 24 December 2019, 8:22:13.600935 pm
UUID: b8603634-08a5-4d7d-9ff9-3cd825e9b1f9
Ancestors: Morphic-mt.1612

When autoEnclose is enabled, and [Backspace] is used to remove an initial opening paren-bracket, also remove the corresponding closing paren-bracket, if present.

=============== Diff against Morphic-mt.1612 ===============

Item was changed:
  ----- Method: Editor>>backspace: (in category 'typing/selecting keys') -----
  backspace: aKeyboardEvent
  "Backspace over the last character."
 
  | startIndex |
  aKeyboardEvent shiftPressed ifTrue: [^ self backWord: aKeyboardEvent].
  startIndex := self markIndex +
  (self hasCaret ifTrue: [0] ifFalse: [1]).
  startIndex := 1 max: startIndex - 1.
+ self class autoEnclose ifTrue: [self checkAndHandleEnclosureDeletionFor: aKeyboardEvent].
-
  ^ self backTo: startIndex!

Item was added:
+ ----- Method: Editor>>checkAndHandleEnclosureDeletionFor: (in category 'private') -----
+ checkAndHandleEnclosureDeletionFor: aKeyboardEvent
+ | openers closers closerIndex nextChar previousChar |
+ openers := '([{'.
+ closers := ')]}'.
+ previousChar := self text
+ at: self startIndex - 1
+ ifAbsent: [ $X ].
+ nextChar := self text
+ at: self startIndex
+ ifAbsent: [ $X ].
+ closerIndex := closers indexOf: nextChar.
+ openers
+ at: closerIndex
+ ifPresent:
+ [ : opener | (opener = previousChar and: [ (closers at: closerIndex) = nextChar ]) ifTrue: [ self forwardDelete: aKeyboardEvent ] ]
+ ifAbsent: [ "do nothing" ]!