Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code - Rename symbol too slow for Python

I'm having this refactoring issue where I try to rename a function through the option "Rename symbol", but it will take a long time. There's a "progress bar" moving endlessly below the document tab. It is taking around 5 min to do the renaming (also with variable names).

Is this a normal behaviour? I have about 10 python files in the same folder of around ~100 lines. BUT, I have a data folder (belonging to the project) with some 100,000 txt files (which is ignored by git, btw). Are this documents also taken into account? Is there a way to only rename in current file?

VS Code version: 1.25.0 Python extension: 2018.6.0

Thanks, Rafa

like image 338
Rafael Boy Avatar asked Jul 08 '18 18:07

Rafael Boy


People also ask

How do you rename a symbol in VS Code?

Renaming is a common operation related to refactoring source code and VS Code has a separate Rename Symbol command (F2). Some languages support rename symbol across files. Press F2 and then type the new desired name and press Enter. All usages of the symbol will be renamed, across files.

How do I rename a VS Code in Python?

Right-click the identifier you wish to rename and select Rename, or place the caret in that identifier and select the Edit > Refactor > Rename menu command (F2), or select the identifier and press Ctrl+R.

Is Python good in VS Code?

PyCharm and VS Code are both excellent tools for writing Python code. However, it is vital to note that while PyCharm is an IDE, VS Code is a code editor that provides a similar experience to an IDE through extensions.


1 Answers

same problem here, it's apparently due to the Rope library (which is being used to do the refactoring) not fully supporting Python 3.

Here is an issue of people describing similar problems - https://github.com/Microsoft/vscode-python/issues/52

Update: Using Jedi instead of Microsoft Python Language Server for intellisense seems to have fixed this problem for me. Just add the following entry to your settings.json file :

"python.jediEnabled": true
like image 160
samaspin Avatar answered Oct 03 '22 15:10

samaspin