Skip to content

Commit

Permalink
core: prefer to ask the grammar handler for insert-stmt; core: fix in…
Browse files Browse the repository at this point in the history
…sert cursor pos after adding new list block
  • Loading branch information
tom95 committed Feb 11, 2022
1 parent b89346d commit bd61eb3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/Sandblocks-Core/SBBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,11 @@ SBBlock >> insertStatementAbove [
SBBlock >> insertStatementAboveOrBelow: anAboveBoolean [

| candidate |
self grammarHandler ifNotNil: [:g |
^ g
block: self;
insertStatementAboveOrBelow: anAboveBoolean].

" default behavior is to find the first parent that can take multiple children "
candidate := self.
[candidate parentSandblock fixedNumberOfChildren and: [candidate isArtefact not]] whileTrue: [candidate := candidate parentSandblock].
Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Core/SBBlockCursor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ SBBlockCursor >> initialize [
SBBlockCursor >> insertPositionIn: aBlock near: aPoint [

aPoint
ifNil: [aBlock cursorPositionsDo: [:pos | (pos class = SBCursorInsert and: [pos container = aBlock]) ifTrue: [^ pos]]]
ifNil: [aBlock cursorPositionsDo: [:pos | (pos class = SBCursorInsert and: [pos container containingSandblock = aBlock]) ifTrue: [^ pos]]]
ifNotNil: [ | best bestDistance |
best := nil.
bestDistance := 20.
Expand Down

0 comments on commit bd61eb3

Please sign in to comment.