-
Notifications
You must be signed in to change notification settings - Fork 38.2k
Description
Refs: #179213
- anyOS @jrieken
- anyOS @ulugbekna
Complexity: 3
Summary:
Notebooks now support CodeActions being run upon save. One extra CodeActionKind has been introduced for CodeActions that apply to the entire scope of the notebook, editing multiple cells (i.e., extracting imports to a top cell, grouping %pip install's, etc.). Source level CodeActions are also supported on an individual cell level. These run in parallel so they are restricted to only editing the resource that is passed to it (the TextDocument of the cell the provider is called upon).
For Notebook Level CodeActions, the provider is only passed the FIRST cell of the notebook, as to not return CodeActions that need to resolve for each cell. Keep this in mind if you choose to create your own provider/action.
Steps to Test:
**note: testing Notebook level CodeActions will require OSS, or tomorrow's (05/31) insiders build
- Download or create your own extension, creating a provider for both cell/source and Notebook CodeActions
- This is a sample extension that has the two providers
- Launch the extension host
- Create a new or open a pre-existing notebook
- This is a playground I use with a couple messy notebooks that can be tested on.
- Go to Settings (UI) and search for
notebook.codeActionsOnSave, and add your CodeActions.- If you use the sample extension, your settings.json should include something like this to test both Cell and Notebook levels:
"notebook.codeActionsOnSave": {
"notebook.cleanImports": true,
"source.fixAll": true,
},- Save the document, triggering the CodeActions. May be easier to ensure they work individually by commenting one or the other CodeAction within your settings, then testing them combined at the end.
Things to check
- CodeActions are applied correctly, the changes desired are applied without error.
- The notebook is clean and saved after all CodeActions are applied.
If you want to do more
- Create a source level CodeAction that applies edit to multiple cells. This should FAIL and not apply, due to the restriction of only editing the given cell/resource
Thanks so much for testing!