Skip to content

Conversation

@cpcallen
Copy link
Collaborator

@cpcallen cpcallen commented Mar 4, 2025

Introduce an "Edit block contents (→)" block context menu option. This is shown any time the cursor is on a block and not in the rightmost position 'on the current line'; consequently the description may sometimes be slightly misleading, because it might not be the contents of the current block that's being navigated to, but rather that of a sibling or parent block. The menu option weights are adjusted to put edit between insert and delete.

Also:

  • Rename the main directional shortcuts to match the names of the corresponding keys. (The corresponding methods on LineCursorare not renamed, as that seems like a riskier change.)
  • Sort inputs in navigation_controller.ts.

Part of #132.

cpcallen added 5 commits March 2, 2025 12:42
Rename the main directional shortcuts to match the names of
corresponding keys.

Not renaming the corresponding methods on LineCursor yet
as that seems like a riskier change.
If there are no inline nodes to the right of the cursor on the
'current line' of the program, hide the Edit option.

This means the menu item is shown any time the cursor is on a
block and not in the rightmost position 'on the current line';
consequently sometimes the description ("Edit block contents")
is possibly misleading, because it might not be the contents of
the _current_ block that's being navigated to, but rather that
of a sibling or parent block.
@cpcallen cpcallen marked this pull request as ready for review March 4, 2025 19:15
@cpcallen cpcallen requested a review from a team as a code owner March 4, 2025 19:15
@cpcallen cpcallen requested review from BenHenning and removed request for a team March 4, 2025 19:15
@cpcallen cpcallen moved this to In Progress in Blockly 2025 Mar 4, 2025
@cpcallen cpcallen marked this pull request as draft March 4, 2025 19:25
@cpcallen
Copy link
Collaborator Author

cpcallen commented Mar 4, 2025

Marking as draft, as somehow I lost a big chunk of code in last commit!

@cpcallen
Copy link
Collaborator Author

cpcallen commented Mar 5, 2025

Turns out this PR is fine; it was my local branch that I had somehow got in to some werid state that was not building.

@cpcallen cpcallen marked this pull request as ready for review March 5, 2025 16:26
Co-authored-by: Matt Hillsdon <[email protected]>
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@cpcallen
Copy link
Collaborator Author

@BenHenning: this remains ready for review.

Copy link
Collaborator

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cpcallen! No major concerns, just some clarification questions. PTAL.

Comment on lines +32 to +33
* This action registers itself only as a context menu item, as there
* is already a corresponding "right" shortcut item.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it perhaps make sense to consolidate this with the shortcut for workspace contexts? It seems to be doing roughly the same thing, and it feels a bit odd to have an inconsistency here as compared to other action classes (where those manage both context menu and shortcut triggers).

It wouldn't seem odd, I think, for there to be a workspace-only shortcut handled here either since the context menu callback and precondition are already assuming workspace only. I suppose the only aspects I'm unsure of is having multiple actions bound for the same key (RIGHT) or whether splitting that into multiple locations is wise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code could be merged in to actions/ws_movement.ts, now that has been separated out in #281.

The precondition for showing the "edit" option is a bit different from the precondition for allowing the right arrow to work, though: the right arrow key is practically always enabled, wheras the edit option is only shown in some places.

(And the edit option will need to be updated once the cursor properly supports RTL, since in that case it will do the same thing as the left arrow key, rather than the right arrow key.)

Unfortunately I won't have time to do such a refactor before I leave today, and I won't be back for a couple of weeks.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to merge this as-is for the benefits of the clean-up. Will approve, thanks!

Copy link
Collaborator

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR LGTM for the clean-up. Any additional cleaning can be done later.

Comment on lines +32 to +33
* This action registers itself only as a context menu item, as there
* is already a corresponding "right" shortcut item.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to merge this as-is for the benefits of the clean-up. Will approve, thanks!

@BenHenning
Copy link
Collaborator

@rachel-fenichel since Chris is out how do you want to handle merging this?

@rachel-fenichel
Copy link
Collaborator

I fixed some merge conflicts/bad imports and am merging now.

@rachel-fenichel rachel-fenichel merged commit 545dfe5 into main Mar 14, 2025
1 check passed
@rachel-fenichel rachel-fenichel deleted the feat/edit branch March 14, 2025 21:06
@github-project-automation github-project-automation bot moved this from In Progress to Done in Blockly 2025 Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants