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

commits at source.squeak.org commits at source.squeak.org
Wed Apr 27 12:21:03 UTC 2022


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

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

Name: Morphic-mt.1972
Author: mt
Time: 27 April 2022, 2:20:57.686668 pm
UUID: 5ff494ac-cefd-4348-a243-cb7ce9be22f7
Ancestors: Morphic-mt.1971

Fixes regression in "set style..." invoked via CMD+SHIFT+K.

Thanks to Nicolas (nice) for the hint!

***

There are a lot of ifNil checks against paragraph in TextMorph. I suppose this is to not invalidate-and-recompute paragraphs by accident, which would further slow down the overall input experience.

In #handleInteraction:fromEvent:, I can see two invariants:

1. The instVar paragraph must never be nil when entering the method.
2. Any "new" paragraph must be processed after "interactionBlock" so that visual glitches regarding the text selection can be avoided.

Thus, replacing all accesses to the instVar "paragraph" with the accessor #paragraph seems too risky performance-wise. For now, I will make sure that the paragraph is notNil after the interactionBlock.

=============== Diff against Morphic-mt.1971 ===============

Item was changed:
  ----- Method: TextMorph>>handleInteraction:fromEvent: (in category 'editing') -----
  handleInteraction: interactionBlock fromEvent: evt
  	"Perform the changes in interactionBlock, noting any change in selection
  	and possibly a change in the size of the paragraph (ar 9/22/2001 - added for TextPrintIts)"
  
  	| oldEditor oldParagraph oldText oldSelection |
  	oldEditor := editor.
  	oldParagraph := paragraph.
  	oldText := oldParagraph text copy.
  	oldSelection := oldParagraph selectionRects. "already copy"
  
+ 	"1) Note old selection to avoid visual glitches."
- 	"Note old selection."
  	self selectionChanged: oldSelection.
  	
+ 	"2) Evaluate the interaction. Ensure access to paragraph."
  	interactionBlock value.
+ 	paragraph ifNil: [self createParagraph].
  
+ 	"3) ?!! Account for premature #releaseEditor ?!!"
+ 	oldParagraph == paragraph ifTrue: [
+ 		self flag: #fixme.
+ 		editor := oldEditor].
- 	(oldParagraph == paragraph) ifTrue:[
- 		"this will not work if the paragraph changed"
- 		editor := oldEditor.     "since it may have been changed while in block"
- 	].
  	
+ 	"4) Note new selection to avoid visual glitches."
- 	"Note new selection."
  	paragraph selectionRects in: [:newSelection |
  		newSelection ~= oldSelection ifTrue: [
  			self selectionChanged: newSelection]].
+ 	
+ 	"5) Update my layout as a morph if necessary."
- 		
  	(oldText = paragraph text and: [ oldText runs = paragraph text runs ])
  		ifFalse: [ self updateFromParagraph ].
  	
  	self flag: #ImmPlugin.
  	"self setCompositionWindow."!



More information about the Squeak-dev mailing list