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

commits at source.squeak.org commits at source.squeak.org
Sat Jan 22 10:57:08 UTC 2022


Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1854.mcz

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

Name: Morphic-mt.1854
Author: mt
Time: 22 January 2022, 11:57:02.701321 am
UUID: be7fdc12-c9c8-8040-a78a-e03ff1c7016f
Ancestors: Morphic-mt.1853

Revise latest updated to #cancelSafely. Ask the model to intervene or do extra clean-ups. Avoid sending that #textEdited: with empty contents.

Thanks to Chris (cmm) for pointing this out! See http://lists.squeakfoundation.org/pipermail/squeak-dev/2022-January/218543.html

=============== Diff against Morphic-mt.1853 ===============

Item was changed:
  ----- Method: PluggableTextMorph>>cancelSafely (in category 'menu commands') -----
  cancelSafely
+ 	"Cancel all edits by replacing the content with the original contents. Retain the undo history. The model can intervene via #okToRevertChanges, which is beneficial if all edits have already be communicated via #textEdited: so that the model can cancel its internal caches."
- 	"Cancel all edits by replacing the content with the original contents. Retain the undo history. If a model is listening to #textEdited and maybe also directly derives #getText from it, clear the edit buffer first, so that a cancel means deleting everything."
  
+ 	(model respondsTo: #okToRevertChanges:) ==> [model okToRevertChanges: editTextSelector]
+ 		ifFalse: [^ self].
+ 
  	self handleEdit: [
- 		self textEdited: ''.
  		textMorph editor replaceAllWith: self getText.
- 		self textEdited: textMorph contents.
  		self selectInterval: self getSelection.
+ 		self hasUnacceptedEdits: false.
+ 		self hasUserEdited: false].!
- 		self hasUnacceptedEdits: false].!

Item was changed:
  ----- Method: PluggableTextMorph>>update: (in category 'updating') -----
  update: aSymbol 
  	aSymbol ifNil: [^self].
  	aSymbol == #flash ifTrue: [^self flash].
  
  	aSymbol == getTextSelector
  		ifTrue: [
  			self setText: self getText.
  			getSelectionSelector
  				ifNotNil: [self setSelection: self getSelection].
  			^ self].
  	aSymbol == getSelectionSelector 
  		ifTrue: [^self setSelection: self getSelection].
  
  	aSymbol == #acceptChanges ifTrue: [^ self accept].
+ 	aSymbol == #revertChanges ifTrue: [^ self cancelSafely].
- 	aSymbol == #revertChanges ifTrue: [^ self cancel].
  
  	(aSymbol == #autoSelect and: [getSelectionSelector notNil]) 
  		ifTrue: 
  			[self handleEdit: 
  					[(textMorph editor)
  						abandonChangeText; "no replacement!!"
  						setSearch: model autoSelectString;
  						findAgainNow "do not reset search string"]].
  	aSymbol == #clearUserEdits ifTrue: [^self hasUnacceptedEdits: false].
  	aSymbol == #wantToChange 
  		ifTrue: 
  			[self canDiscardEdits ifFalse: [^self promptForCancel].
  			^self].
  	aSymbol == #appendEntry 
  		ifTrue: 
  			[self handleEdit: [self appendEntry].
  			^self refreshWorld].
  	aSymbol == #appendEntryLater
  		ifTrue: [self handleEdit: [self appendEntry]].
  	aSymbol == #clearText 
  		ifTrue: 
  			[self handleEdit: [self changeText: Text new].
  			^self refreshWorld].
  	aSymbol == #bs 
  		ifTrue: 
  			[self handleEdit: [self bsText].
  			^self refreshWorld].
  	aSymbol == #codeChangedElsewhere 
  		ifTrue: 
  			[self hasEditingConflicts: true.
  			^self changed].
  	aSymbol == #saveContents
  		ifTrue:
  			[^(self respondsTo: #saveContentsInFile) ifTrue: [self saveContentsInFile]].
  	aSymbol == #showContents
  		ifTrue:
  			[^ self scrollToTop].
  !

Item was added:
+ ----- Method: SearchBar>>okToRevertChanges: (in category 'user edits') -----
+ okToRevertChanges: aspect
+ 	"Clear caches since we use #textEdited: callback from view."
+ 
+ 	aspect = #searchTermSilently: ifTrue: [searchTerm := ''].
+ 	^ true!



More information about the Squeak-dev mailing list