[squeak-dev] The Trunk: Morphic-mt.1811.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Dec 3 15:51:19 UTC 2021

Marcel Taeumel uploaded a new version of Morphic to project The Trunk:

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

Name: Morphic-mt.1811
Author: mt
Time: 3 December 2021, 4:51:11.88585 pm
UUID: 7dabb569-a037-7048-abe7-9eccf7032c45
Ancestors: Morphic-mt.1810

Fixes a nasty text undo bug, that (I think) occurred when interleaving normal edits with paste-from-clipboard.

Also makes #cancelSafely (i.e. CMD+L) more robust.

=============== Diff against Morphic-mt.1810 ===============

Item was changed:
  ----- Method: PluggableTextMorph>>cancelSafely (in category 'menu commands') -----
  	"Cancel all edits by replacing the content with the original contents. Retain the undo history."
  	self handleEdit: [
+ 		textMorph editor replaceAllWith: self getText.
+ 		self selectInterval: self getSelection.
- 		textMorph editor
- 			selectAll;
- 			replaceSelectionWith: self getText;
- 			selectAt: 1.
  		self hasUnacceptedEdits: false].!

Item was changed:
  ----- Method: TextEditor>>closeTypeIn (in category 'typing support') -----
  	"See comment in openTypeIn.  It is important to call closeTypeIn before executing
  	 any non-typing key, making a new selection, etc.  It is called automatically for
  	 menu commands."
+ 	| begin start stop |
- 	| begin stop |
  	beginTypeInIndex ifNotNil:
  		[begin := beginTypeInIndex.
  		stop := self stopIndex.
+ 		start := self startIndex.
  		self history ifNotNil:
  			 myHistory current
  				contentsAfter: (stop <= begin
  					ifTrue: [self nullText]
  					ifFalse: [paragraph text copyFrom: begin to: stop-1]);
+ 				intervalAfter: (start to: stop-1);
- 				intervalAfter: (stop to: stop-1);
  				intervalBetween: (stop < begin
  					ifTrue: [stop to: stop-1]
  					ifFalse: [begin to: stop-1]);
  				messageToUndo: (Message selector: #undoAndReselect);
  				messageToRedo: (Message selector: #redoAndReselect).
  			myHistory finishRemember].
  		beginTypeInIndex := nil]!

Item was changed:
  ----- Method: TextEditor>>replace:with:and: (in category 'undo') -----
  replace: xoldInterval with: newText and: selectingBlock 
  	"Replace the text in oldInterval with newText and execute selectingBlock to establish the new selection.  Create an undoAndReselect:redoAndReselect: undoer to allow perfect undoing."
  	| undoInterval |
  	undoInterval := self selectionInterval.
+ 	undoInterval = xoldInterval ifFalse: [
+ 		self selectInvisiblyFrom: xoldInterval start to: xoldInterval stop].
- 	undoInterval = xoldInterval ifFalse: [self selectInterval: xoldInterval].
  	self zapSelectionWith: newText.
  	selectingBlock value.
  	otherInterval := self selectionInterval.!

Item was added:
+ ----- Method: TextEditor>>replaceAllWith: (in category 'undo') -----
+ replaceAllWith: aText
+ 	"Like #paste but replacing all contents with aText."
+ 	self closeTypeIn.
+ 	self selectInvisiblyFrom: 1 to: self text size.
+ 	self openTypeIn.
+ 	self zapSelectionWith: aText.
+ 	self closeTypeIn.!

More information about the Squeak-dev mailing list