microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.29k stars 1.18k forks source link

Add a command to restart the language server #22045

Open Saltsmart opened 1 year ago

Saltsmart commented 1 year ago

This has been discussed for vscode-python extension. A command called restartLanguageServer has been created.

However this command can't be found in my command palette, maybe in pylance extension it's already deleted. I'd like a way to re-analyse the code in a jupyter notebook, since the language server (or the extension) is always broken weirdly microsoft/pylance-release#4736.

debonte commented 1 year ago

It's Python: Restart Language Server. Do you not see that in the command palette?

image

stevesimmons commented 1 year ago

I have similar problems with Pylance working for a while in a Jupyter notebook, then breaking.

It's Python: Restart Language Server. Do you not see that in the command palette?

For me, when the active VSC window is a Jupyter notebook, the command palette has Restart Language Server just for .Net, nothing for Python. Conversely, when the active VSC window is a Python file, the "Python: Restart Language Server" command does appear.

Saltsmart commented 1 year ago

It's Python: Restart Language Server. Do you not see that in the command palette?

image

When the editor opens a .py file, this appears:

Snipaste_2023-08-26_09-57-22

However when in a jupyter notebook, this command vanishs:

Snipaste_2023-08-26_09-58-17

Here is my environment and extension info:

Version: 1.81.1 (system setup)
Commit: 6c3e3dba23e8fadc360aed75ce363ba185c49794
Date: 2023-08-09T22:22:42.175Z
Electron: 22.3.18
ElectronBuildId: 22689846
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22000

Name: Python
Id: ms-python.python
Description: IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), code formatting, refactoring, unit tests, and more.
Version: 2023.14.0
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.python

Name: Pylance
Id: ms-python.vscode-pylance
Description: A performant, feature-rich language server for Python in VS Code
Version: 2023.8.40
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance

Name: Jupyter Notebook Renderers
Id: ms-toolsai.jupyter-renderers
Description: Renderers for Jupyter Notebooks (with plotly, vega, gif, png, svg, jpeg and other such outputs)
Version: 1.0.17
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter-renderers

Name: Jupyter
Id: ms-toolsai.jupyter
Description: Jupyter notebook support, interactive programming and computing that supports Intellisense, debugging and more.
Version: 2023.7.1002162226
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter

Name: Flake8
Id: ms-python.flake8
Description: Linting support for python files using `flake8`.
Version: 2023.6.0
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.flake8

Name: Black Formatter
Id: ms-python.black-formatter
Description: Formatting support for python files using `black`.
Version: 2023.4.1
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter
debonte commented 1 year ago

@DonJayamanne, this reminds me that the language status {} button also doesn't show for notebooks. Maybe this should be solved in a general way for all languages rather than in a Python-specific way? Has this come up before?

image

DonJayamanne commented 1 year ago

I think @mjbvz would be the best person to answer this .

alexmerm commented 11 months ago

Can confirm I have the same issue(works in python file, doesn't show up in jupyter file) for the following environment

Version: 1.82.2 (Universal)
Commit: abd2f3db4bdb28f9e95536dfa84d8479f1eb312d
Date: 2023-09-14T05:59:47.790Z
Electron: 25.8.1
ElectronBuildId: 23779380
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 22.6.0

Name: Black Formatter
Id: ms-python.black-formatter
Description: Formatting support for Python files using `black`.
Version: 2023.4.1
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter

Name: isort
Id: ms-python.isort
Description: Import Organization support for Python files using `isort`.
Version: 2023.10.1
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.isort

Name: Jupyter
Id: ms-toolsai.jupyter
Description: Jupyter notebook support, interactive programming and computing that supports Intellisense, debugging and more.
Version: 2023.8.1002501831
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter

Name: Pylance
Id: ms-python.vscode-pylance
Description: A performant, feature-rich language server for Python in VS Code
Version: 2023.10.20
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance

Name: Python
Id: ms-python.python
Description: IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), code formatting, refactoring, unit tests, and more.
Version: 2023.18.0
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.python
ferstlf commented 6 months ago

Hi! Has there been any progress on this? We just ran into the same problem and it's quite annoying.

The "Python: Restart Language Server" command is listed in Python files but not in Jupyter notebooks. The "Python: Show Language Server Output" command, however, does show up in any file. So I'm wondering, would this just be a one-line change to remove the editorLangId == python in the when-condition of the restart command in package.json? To make it match the when-condition of the show-output command.