microsoft / vscode

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

Navigation (find references) and refactoring (rename) across closed notebooks #211829

Closed stephenkraemer closed 3 months ago

stephenkraemer commented 6 months ago

I am not sure if this is a vscode issue or a language server feature request, thank you for considering it.

It would be very helpful to allow reference finding and rename refactoring across both closed and open notebooks.

Reproducible basic use cases have been document in #177391 (rename of a module function imported into a module) and in microsoft/pylance-release#5175 (reference search across all notebooks, closed and open). I hope that by combining these feature request here this issue can attract some votes :)

The current state of this feature is unclear to me. When I set up the test case from #177391 and open both the notebook and the module, refactoring with pylance sometimes does rename in the notebook, and sometimes it does not. Renaming never works when the notebook is closed. I have found no documentation on this except for the issues mentioned above.

I would argue that it is a very common pattern in data science coding to write functions into a python module and then import these functions into a notebook. This makes linting and maintaining the code much easier, because it isolates functions from global variables in the notebook and communicates clearly what the inputs and outputs of processing steps are. Extracting functions to modules is also required for some types of parallel computations.

As another point to indicate the potentially large user group for this feature, navigation and refactoring across notebooks and scripts has just been implemented in PyCharm, where it was highly requested and discussed. It would be awesome to be able to leverage this in vscode!

stephenkraemer commented 4 months ago

Sorry for bumping this... I was just wondering whether you could very briefly sketch whether this feature is on the roadmap at all, or completely out of scope? That would inform whether I need to invest some time to find a workaround for this, and perhaps this info could also be valuable for other people. Thanks a lot!

jrieken commented 3 months ago

I am not sure if this is a vscode issue or a language server feature request, thank you for considering it.

Thanks for patience. This is one for the extension, the mechanics are all there and will work once the extension/language server gets this working.