interactive icon indicating copy to clipboard operation
interactive copied to clipboard

Opening locally saved notebook will grey out all syntax, auto-detect can find languages not relevant to cell's kernel

Open Octanoz opened this issue 2 years ago • 5 comments

Describe the bug

I changed folders in VS Code and the notebook that I had active there is now showing all syntax greyed out. They are all C# kernel - C# script cells. Changing the language mode of the cell from Code to Auto Detect has mixed results with the auto-detect finding TypeScript and JavaScript where there is only C#. It seems odd that it's a possibility at all to find these language in a C# cell.

This behaviour is maintained even when creating a new cell and writing some C# code there.

There are no issues with running any of the cells, just the syntax highlighting is not working correctly.

This seems to be related to https://github.com/dotnet/interactive/issues/2683 but for a local copy as some people had mentioned there as well.

[Edit] I just got a pop-up about the active document not being a part of the workspace. Perhaps that's relevant so I'll add the screenshot. If the C# logs are of interest I can provide those as well.

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

Version: 1.0.556801+2d9726b514498cd84403a1d5d13da3161c99eab2 Library version: 1.0.0-beta.24568.1+2d9726b514498cd84403a1d5d13da3161c99eab2 Build date: 2024-11-19T21:23:41.1573504Z

  • OS
    • [x] Windows 11
    • [ ] Windows 10
    • [ ] macOS
    • [ ] Linux (Please specify distro)
    • [ ] iOS
    • [ ] Android
  • Browser
    • [x] Chrome
    • [ ] Edge
    • [ ] Firefox
    • [ ] Safari
  • Frontend
    • [ ] Jupyter Notebook
    • [ ] Jupyter Lab
    • [ ] nteract
    • [x] Visual Studio Code
    • [ ] Visual Studio Code Insiders
    • [ ] Visual Studio
    • [ ] Other (please specify)

Screenshots

Image

Using Auto Detect Image

Image

Octanoz avatar Nov 29 '24 17:11 Octanoz

I was unable to reproduce the missing syntax highlighting.

I changed folders in VS Code and the notebook that I had active there is now showing all syntax greyed out.

Can you describe exactly how you did this? I tried File > Open folder and the notebook was closed in the process.

The Auto-detect feature in notebooks is a VS Code feature that's unaware of the .NET Interactive subkernels. It will really only change the VS Code-controlled syntax highlighting, but the cell might then not be properly associated with a subkernel that can actually run it. This is a known issue without a clear solution.

The warning The active document is not part of the open workspace is coming from the C# extension which is unaware of notebooks.

jonsequitur avatar Dec 02 '24 19:12 jonsequitur

Can you describe exactly how you did this? I tried File > Open folder and the notebook was closed in the process.

Sure, my usual setup is all my code windows on the left and I usually have a markdown preview as well as a notebook open in the right editor. I tend to keep the notebooks in their own Notes folder as well.

And then it's really just the following:

  1. File > Close Folder
  2. Work on another solution from the recent list
  3. Close that one
  4. Open original solution from recent
  5. Code files load in on the left, notebook on the right, language servers connect, etc.
  6. Notebook cells stay greyed out unless Code is manually switched to Auto Detect

I just kept the C# output window open while changing to Auto Detect and it seems that particularly for the cells with an #!import someScript.csx command that I'm getting about a dozen warnings like this one:

2024-12-05 02:06:15.916 [info] [Warn - 2:06:15 AM] [LanguageServerHost] Text for vscode-notebook-cell:/c:/Project/Notes.dib#W0sZmlsZQ== did not match document text (DocumentId, #33e1a221-b6cf-43c3-914a-77dc62b517a7 - vscode-notebook-cell:/c:/Project/Notes.dib#W1sZmlsZQ==) in workspace's MiscellaneousFiles current solution

Switching all cells back to Code will trigger the active document not part of workspace popup.

Octanoz avatar Dec 05 '24 01:12 Octanoz

I'm still not able to reproduce the grayed out syntax, assuming that I followed the steps correctly. Are you able to send a video?

jonsequitur avatar Dec 05 '24 01:12 jonsequitur

I'm experiencing a bit of a "watched pot" scenario where yesterday every notebook previously used was greyed out and now every single one of them has syntax highlighting working as expected.

Hopefully it was something with my system. I did disable the SonarLint / SonarQube extension because it was annoying me. That's really the only thing I changed myself since yesterday.

Should the highlighting be gone again over the weekend and/or I figure out what breaks it I'll report back here. Thank you for your time either way, Jon.

Octanoz avatar Dec 05 '24 12:12 Octanoz

You're welcome @Octanoz. I'll close the issue but feel free to reopen it if it comes back and we can keep digging.

jonsequitur avatar Dec 05 '24 19:12 jonsequitur