-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Description
Refs: #212381
- anyOS @bpasero
- anyOS @Tyriar
- anyOS @karthiknadig
Complexity: 5
author: @Yoyokrazy
Summary:
Support for notebook scoped formatting via code actions is now supported with the Code Action Kind notebook.format.xyz
. This is to enable formatters to provide richer edits that are able to leverage the NotebookEdit
type, allowing them to add, delete, and shift cells, in addition to all of the standard textual edits within a cell.
The intended user story for this feature is as follows: The user will install an extension that provides a notebook.format.xyz
code action. To the user, they shouldn't need to know anything about the implementation details, or about the fact that it will provide a code action, rather than document formatting edits. The inner workings of the format code action should be controlled via the extension settings. The user should be able to control the behavior of this feature from the settings menu by turning on or off format on save or setting a different default formatter.
Steps to test:
This section is going to be flexible, allowing testers to either develop and test via their own extension, or by tweaking an extension sample I have already created here. You can trigger this formatting code action by enabling the setting notebook.formatOnSave.enabled
. You can also define this in notebook.codeActionsOnSave
and although this is not the intended use, it would be good to do this to check for any notebook-breaking behaviors.
Things to look out for:
- Read through the referenced issue to get an idea of some of the best practices for defining code action providers, and some of the common issues that people run into. If you can try to poke holes in this, great. This is currently in development and in talks with ruff and black, so the goal is to get feedback so this better suits everyone's needs.
- If you have two extensions providing a
notebook.format.xyz
code action, you should receive a warning, and be prompted to update thenotebook.defaultFormatter
setting. This will have you set the fully qualified extension id of the code action provider that will handle formatting- Make sure that the correct code action is being applied as well