microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.74k stars 28.72k forks source link

WorkspaceConfiguration update fails if TextDocument is a Notebook #134103

Closed Jason3S closed 2 years ago

Jason3S commented 2 years ago

Issue Type: Bug

Fails to update Workspace folder settings

API: WorkspaceConfiguration.update | Visual Studio Code Extension API

When calling update workspace folder settings on a WorkspaceConfiguration where the resource is a Notebook TextDocument, it will fail. It will also fail if the resource is a URI.

Example URI

vscode-notebook-cell:/Users/jason/code/tests/jupyter/getting-started/sample.ipynb#ch0000000

Stack

  cause: Error: Unable to write to Folder Settings because no resource is provided.
      at I.toConfigurationEditingError (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1935:18825)
      at I.validate (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1935:22169)
      at I.doWriteConfiguration (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1935:15186)
      at Object.factory (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1935:15020)
      at d.consume (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:77:16583)
      at vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:77:16398
      at new Promise (<anonymous>)
      at d.queue (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:77:16322)
      at I.writeConfiguration (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1935:15005)
      at I.writeConfigurationValue (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1935:44653)
      at vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1935:30793
      at Array.map (<anonymous>)
      at I.updateValue (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1935:30781)
      at processTicksAndRejections (internal/process/task_queues.js:93:5) {

Related to: Add words to workspace / folder settings does not work in Jupyter Notebooks · Issue #1353 · streetsidesoftware/vscode-spell-checker

VS Code version: Code 1.60.2 (7f6ab5485bbc008386c4386d08766667e155244e, 2021-09-22T11:59:27.195Z) OS version: Darwin x64 20.6.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (16 x 2300)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|1, 2, 2| |Memory (System)|32.00GB (0.12GB free)| |Process Argv|--crash-reporter-id 21ae0ece-62a2-4681-a5cf-c687ea23e753| |Screen Reader|no| |VM|0%|
Extensions (49) Extension|Author (truncated)|Version ---|---|--- ada|Ada|22.0.11 commit-message-editor|ada|0.19.0 alignment|ann|0.3.0 vscode-zipfs|arc|2.3.0 vscode-intelephense-client|bme|1.7.1 better-toml|bun|0.3.2 scala|dal|0.0.5 vscode-eslint|dba|2.1.25 gitlens-insiders|eam|2021.7.1905 EditorConfig|Edi|0.16.4 vscode-npm-script|eg2|0.3.22 prettier-vscode|esb|9.0.0 vscode-graphql|Gra|0.3.18 mediawiki|jak|2.1.0 latex-workshop|Jam|8.20.2 svg|joc|1.4.10 language-haskell|jus|3.4.0 vscode-cfml|Kam|0.5.3 linter-gfortran|krv|2.3.0 remotefs|lix|0.0.16 Kotlin|mat|1.7.1 vscode-apache|mrm|1.2.0 vscode-puglint|mrm|2.3.0 vscode-docker|ms-|1.17.0 python|ms-|2021.9.1246542782 vscode-pylance|ms-|2021.9.3 jupyter|ms-|2021.8.2041215044 jupyter-keymap|ms-|1.0.0 remote-containers|ms-|0.194.3 azure-account|ms-|0.9.8 cpptools|ms-|1.6.0 vsonline|ms-|1.0.3076 marko|pca|0.4.0 java|red|0.82.0 es6-mocha-snippets|spo|0.2.2 avro|str|0.5.0 code-spell-checker|str|2.0.8-alpha.0 code-spell-checker-dutch|str|0.2.9 code-spell-checker-german|str|2.0.1 code-spell-checker-persian|str|0.1.9 code-spell-checker-portuguese-brazilian|str|2.0.2 code-spell-checker-russian|str|2.0.1 code-spell-checker-spanish|str|2.0.2 code-spell-checker-swedish|str|1.0.1 code-spell-checker-turkish|str|0.1.9 code-spell-checker-ukrainian|str|0.1.10 hunspell|str|0.0.2 vscodeintellicode|Vis|1.2.14 vscode-java-debug|vsc|0.36.0
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 pythonvspyt602:30300191 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyt639:30300192 pythontb:30283811 pythonvspyt551cf:30345471 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30358481 pythondataviewer:30285071 pythonvsuse255:30340121 vscod805:30301674 pythonvspyt200:30340761 binariesv615:30325510 vsccppwtct:30364498 pythonvssor306:30344512 bridge0708:30335490 pygetstartedt2:30371810 dockerwalkthru:30370836 bridge0723:30353136 pythonrunftest32:30373476 pythonf5test824:30373475 javagetstartedc:30364665 pythonvspyt187:30373474 pydsgsc2:30361791 ```
sandy081 commented 2 years ago

It seems vscode-notebook-cell:/Users/jason/code/tests/jupyter/getting-started/sample.ipynb#ch0000000 is not a valid workspace resource - as the workspace returns no workspace folder for this resource.

https://github.com/microsoft/vscode/blob/a0a448f344bc8c068deb1202708dfc1e7c17ef89/src/vs/platform/workspace/common/workspace.ts#L60-L64

cc @rebornix

Jason3S commented 2 years ago

@sandy081,

That is the whole issue. How to get the canonical form of the URI? As an extension that received the URI, other than to magically know to convert it to: file://Users/jason/code/tests/jupyter/getting-started/sample.ipynb, what should I do?

Jason3S commented 2 years ago

Please note: This run counter to Supporting Remote Development and GitHub Codespaces | Visual Studio Code Extension API

sandy081 commented 2 years ago

That is the whole issue. How to get the canonical form of the URI? As an extension that received the URI, other than to magically know to convert it to: file://Users/jason/code/tests/jupyter/getting-started/sample.ipynb, what should I do?

Requesting @rebornix to answer this

Jason3S commented 2 years ago

@rebornix, Is there an answer for this?

How do I get the canonical form of a URI for an open Notebook?

rebornix commented 2 years ago

@Jason3S when you get the cell uri, you can try to find a notebook document vscode.workspace.notebookDocuments whose uri path matches the cell uri path, which would be a valid resource uri to use.