Skip to content

Commit

Permalink
move vertically to closest text fields rather than closest blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95 committed Apr 16, 2021
1 parent 3357d9c commit 3bac95f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions packages/Sandblocks-Core/SBBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1581,22 +1581,21 @@ 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.
allCandidates do: [:candidate | | distance |
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 }
Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Smalltalk/SBStNewMessageSend.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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)]].
Expand Down

0 comments on commit 3bac95f

Please sign in to comment.