Skip to content

Heuristic insert #354

@microbit-matt-hillsdon

Description

@microbit-matt-hillsdon

From previous discussions we've agreed:

  1. to go with a more heuristic notion of insert when the stationary/target node is a block
  2. to prefer inserting after a block to before it when the cursor is on a block

There are still quite a few questions to iron out. Having said that, I think we should make a move in this direction ASAP even if we revisit the details.

It's tempting to treat statement and value blocks the same way but statement blocks compose trivially via next/previous, but value blocks only sometimes compose as they may or may not have inputs. That might not matter but it seems a difference to keep in mind.

Some areas to consider:

  • Should we always prefer the first statement/value input? Or the first non-connected?
    • Is the answer different for statement and value blocks?
    • If we go with first-non-connected and all are connected, what do we do in the fallback case?
      • Is the answer the different for statement and value blocks?
  • Do we prefer a block's statement input to the block's next connection? Learning towards yes for this one for based on feedback from @kmcnaught and consistency with the top-level, C-shaped case.
  • Do we try to take into account the connection checker?

Because the selection moves to the newly inserted block, in practice the "first non-connected vs first" decision doesn't seem as key as I thought it was.

I'll open a initial PR with a relatively simple version that prefers first matching statement/value input regardless of whether it's connected; appends to statement inputs, then tries next connections, failing that the output connection wrap around/displace behaviour.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions