Repository: vscode
Issue: VS Code does not send code action to LSP server on save when running on a notebook file
Labels: bug,notebook-code-actions

Type: <b>Bug</b>

Ruff (a linting/formatting extension for Python) has been having an issue involving notebook documents not being formatted on save, even with the right configuration. After investigating, we determined that the issue was that VS Code was not sending a code action request to the LSP on save, which doesn't seem like the right behavior.

To reproduce, you'll first need to install the [Ruff extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff).

Next, add this to your `settings.json`:
```json
{
  "editor.codeActionsOnSave": {
    "source.fixAll": "always",
    "source.organizeImports": "always"
  },
  "editor.formatOnSave": true,
  "notebook.formatOnSave.enabled": true,
  "notebook.codeActionsOnSave": {
    "notebook.source.fixAll": "explicit",
    "notebook.source.organizeImports": "explicit"
  },
}
```

Then, with the Ruff extension enabled, create or open a Jupyter notebook file that has unorganized imports. A simple example would be to have a single code cell that looks like the following:
```python
import string
import functools
```

Then, manually save the notebook (`Ctrl/Cmd+S`). The imports are neither re-organized nor are they removed, which they should be. This works if you put it in a normal Python file - this only seems to happen with a Jupyter Notebook.

It seems that VS Code isn't sending any code actions during a manual save on a Jupyter Notebook, unlike normal files, where it does.

VS Code version: Code 1.90.1 (Universal) (611f9bfce64f25108829dd295f54a6894e87339d, 2024-06-11T21:02:41.372Z)
OS version: Darwin arm64 23.5.0
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Apple M3 Max (14 x 2400)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: enabled_on<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_graphite: disabled_off<br>video_decode: enabled<br>video_encode: enabled<br>webgl: enabled<br>webgl2: enabled<br>webgpu: enabled|
|Load (avg)|2, 3, 3|
|Memory (System)|36.00GB (2.40GB free)|
|Process Argv|--crash-reporter-id bb0f7ee6-0b5f-46b6-94a6-78414cb3a99f|
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (17)</summary>

Extension|Author (truncated)|Version
---|---|---
tsl-problem-matcher|amo|0.6.2
ruff|cha|2024.28.0
vscode-eslint|dba|3.0.10
prettier-vscode|esb|10.4.0
file-icons|fil|1.1.0
insta|mit|1.0.7
debugpy|ms-|2024.6.0
python|ms-|2024.8.1
vscode-pylance|ms-|2024.6.1
jupyter|ms-|2024.5.0
jupyter-keymap|ms-|1.1.2
jupyter-renderers|ms-|1.0.18
vscode-jupyter-cell-tags|ms-|0.1.9
vscode-jupyter-slideshow|ms-|0.1.6
vscode-xml|red|0.27.1
rust-analyzer|rus|0.3.2002
vscode-lldb|vad|1.10.0

(1 theme extensions excluded)

</details><details>
<summary>A/B Experiments</summary>

```
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
jchc7451:31067544
chatpanelt:31048053
dsvsc021:30996838
724cj586:31013169
pythoncenvpt:31062603
a69g1124:31058053
dvdeprecation:31068756
pythonprt:31056678
dwnewjupyter:31046869
2f103344:31071589

```

</details>

<!-- generated by issue reporter -->