From 3bac95fbac528e8bb12a30e3ab5cd567d2d39866 Mon Sep 17 00:00:00 2001 From: Tom Beckmann Date: Fri, 16 Apr 2021 11:59:34 +0200 Subject: [PATCH] move vertically to closest text fields rather than closest blocks --- packages/Sandblocks-Core/SBBlock.class.st | 13 ++++++------- .../SBStNewMessageSend.class.st | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/Sandblocks-Core/SBBlock.class.st b/packages/Sandblocks-Core/SBBlock.class.st index 364615c4..b9e4e2f0 100644 --- a/packages/Sandblocks-Core/SBBlock.class.st +++ b/packages/Sandblocks-Core/SBBlock.class.st @@ -1581,9 +1581,7 @@ SBBlock >> nextVerticalNear: aNumber calcDistance: aDistBlock validBlock: aValid artefact := self containingFloat. tolerance := 10. - allCandidates := Array streamContents: [:stream | - artefact allBlocksDo: [:candidate | - (candidate hasChildSandblocks not and: [aValidBlock value: candidate]) ifTrue: [stream nextPut: candidate]]]. + allCandidates := Array streamContents: [:stream | artefact allMorphsDo: [:candidate | (candidate isTextMorph and: [aValidBlock value: candidate]) ifTrue: [stream nextPut: candidate]]]. candidates := OrderedCollection new. candidatesBestDistance := 900000000. @@ -1591,12 +1589,13 @@ SBBlock >> nextVerticalNear: aNumber calcDistance: aDistBlock validBlock: aValid distance := aDistBlock value: candidate. distance < candidatesBestDistance ifTrue: [ - (candidatesBestDistance between: distance and: distance + tolerance) ifTrue: [candidates add: candidate] ifFalse: [candidates := OrderedCollection with: candidate]. + (candidatesBestDistance between: distance and: distance + tolerance) + ifTrue: [candidates add: candidate] + ifFalse: [candidates := OrderedCollection with: candidate]. candidatesBestDistance := distance] - ifFalse: [ - (distance between: candidatesBestDistance and: candidatesBestDistance + tolerance) ifTrue: [candidates add: candidate]]]. + ifFalse: [(distance between: candidatesBestDistance and: candidatesBestDistance + tolerance) ifTrue: [candidates add: candidate]]]. - ^ candidates detectMin: [:candidate | (candidate left - artefact left to: candidate right - artefact left) distanceTo: aNumber] + ^ (candidates detectMin: [:candidate | (candidate left - artefact left to: candidate right - artefact left) distanceTo: aNumber]) ifNotNil: #containingSandblock ] { #category : #callbacks } diff --git a/packages/Sandblocks-Smalltalk/SBStNewMessageSend.class.st b/packages/Sandblocks-Smalltalk/SBStNewMessageSend.class.st index e38ff6cf..64fa22c3 100644 --- a/packages/Sandblocks-Smalltalk/SBStNewMessageSend.class.st +++ b/packages/Sandblocks-Smalltalk/SBStNewMessageSend.class.st @@ -219,7 +219,7 @@ SBStNewMessageSend >> useSuggestion: aString [ ifAbsent: [ stream nextPut: ((SBInsertCommand newFor: self containingArtefact) container: self; - morph: (self newNullBlock + morph: ((self newEmptyChildNear: nil before: false) contents: partContents; argumentLabel: (possibleArgumentNames at: index ifAbsent: [])); index: index + 1)]].