pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Symbol renaming in Jupyter notebooks only works in a single cell

Open tigerhawkvok opened this issue 2 years ago • 5 comments

Issue Type: Bug

  1. Have a variable used in many cells
  2. Rename the variable with the "rename symbol" refactor option

expected: all instances renamed reality: only changes instances in that cell

VS Code version: Code 1.68.1 (30d9c6cd9483b2cc586687151bcbcd635f373630, 2022-06-14T12:48:58.283Z) OS version: Windows_NT x64 10.0.19044 Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (16 x 2304)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.73GB (17.90GB free)
Process Argv --crash-reporter-id 3020d701-5128-48b2-bdaf-f271c4aaa329
Screen Reader no
VM 0%
Extensions (75)
Extension Author (truncated) Version
vscode-sql-formatter adp 1.4.4
vscode-caniuse aga 0.5.0
sqlformatter bre 0.0.7
better-toml bun 0.3.2
vscode-postgres cko 1.4.0
excel-to-markdown-table csh 1.3.0
vscode-svgviewer css 2.0.0
vbscript Dar 1.0.4
empty-indent Dmi 0.2.0
githistory don 0.6.19
parquet-viewer dvi 2.2.0
gitlens eam 12.1.2
vscode-html-css ecm 1.13.0
EditorConfig Edi 0.16.4
LogFileHighlighter emi 2.16.0
indent-switcher eph 1.2.1
vscode-uppercasesql epl 2.1.4
terraform-autocomplete erd 0.0.8
vscode-mysql for 0.4.1
copilot Git 1.31.6194
remotehub Git 0.36.0
mdmath goe 2.7.4
gc-excelviewer Gra 4.2.55
live-html-previewer hdg 0.3.0
tasks-statusbar hed 0.1.0
mysql-syntax jak 1.3.1
cypher-query-language jak 1.0.2
latex-workshop Jam 8.27.2
language-julia jul 1.6.24
php-cs-fixer jun 0.3.1
indentation-level-movement kai 1.2.1
stata-enhanced kyl 1.6.1
vscode-emacs-friendly lfs 0.9.0
rainbow-csv mec 2.4.0
code-beautifier mic 2.3.3
dotenv mik 1.0.1
vscode-apache mrm 1.2.0
vscode-less mrm 0.6.3
vscode-docker ms- 1.22.1
data-workspace-vscode ms- 0.2.2
mssql ms- 1.15.0
sql-bindings-vscode ms- 0.2.1
vscode-postgresql ms- 0.3.0
python ms- 2022.10.0
vscode-pylance ms- 2022.7.30
jupyter ms- 2022.5.1001601848
jupyter-keymap ms- 1.0.0
jupyter-renderers ms- 1.0.8
remote-containers ms- 0.241.3
remote-ssh ms- 0.84.0
remote-ssh-edit ms- 0.80.0
remote-wsl ms- 0.66.3
vscode-remote-extensionpack ms- 0.21.0
cpptools ms- 1.10.8
powershell ms- 2022.6.3
remote-repositories ms- 0.12.0
color-highlight nau 2.5.0
indent-rainbow ode 8.3.1
geo-data-viewer Ran 2.5.0
vscode-data-preview Ran 2.3.0
vscode-commons red 0.0.6
vscode-yaml red 1.9.1
remove-tabs-on-save red 1.2.4
vscode-sql-beautify sen 0.0.4
vscode-autohotkey sle 0.2.2
vba-snippets spe 1.0.1
vscode-taskexplorer spm 2.9.1
code-spell-checker str 2.3.0
open-in-browser tec 2.0.0
html-preview-vscode tht 0.2.5
latex-support tor 3.10.0
vscodeintellicode Vis 1.2.22
vscode-arduino vsc 0.4.12
php-debug xde 1.27.0
markdown-pdf yza 1.4.4

(3 theme extensions excluded)

A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vscscmwlcmt:30465135
cppdebug:30492333
pylanb8912:30520716
vsclangdf:30486550

tigerhawkvok avatar Jul 14 '22 19:07 tigerhawkvok

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.69.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

VSCodeTriageBot avatar Jul 14 '22 19:07 VSCodeTriageBot

Would this be pylance or python? Not sure which extension provides the rename symbol command.

rchiodo avatar Jul 15 '22 21:07 rchiodo

Thanks for the report, unfortunately, this is not enough data for us to debug.

Would you please add the information in the report as described in the troubleshooting guide?

judej avatar Jul 19 '22 17:07 judej

This repros for me with or without the LSP notebooks experiment. I was expecting that rename would work in concat doc scenarios. Not sure why it doesn't.

cell 1:

foo = 1
foo = 2

cell 2:

print(foo)

Renaming foo in cell 1 causes it to be renamed on both of cell 1's lines, but not in cell 2. Renaming foo in cell 2 gives This element can't be renamed which seems weird also.

debonte avatar Jul 19 '22 19:07 debonte

Would this be pylance or python? Not sure which extension provides the rename symbol command.

Sorry! I've been at conferences and conventions for almost three weeks nonstop. I have both installed (I actually think both ship by default?) so I don't think I have a ready environment to see which extension provides it. I'll try to spin up a VM or something to see which extension provides that rename command; but I think the underlying issue might be the document is exposed to the extension because it works normally.

I can also confirm the problem still exists as of

Version: 1.69.2 (system setup) Commit: 3b889b090b5ad5793f524b5d1d39fda662b96a2a Date: 2022-07-18T16:12:52.460Z Electron: 18.3.5 Chromium: 100.0.4896.160 Node.js: 16.13.2 V8: 10.0.139.17-electron.0 OS: Windows_NT x64 10.0.19044

tigerhawkvok avatar Jul 26 '22 18:07 tigerhawkvok

I'll try to spin up a VM or something to see which extension provides that rename command

@tigerhawkvok, no worries. We've got it. Rich works on a different team and was just asking for clarification on whether rename was owned by Pylance. It is.

debonte avatar Aug 11 '22 17:08 debonte

This issue has been fixed in version 2022.8.21, which we've just released. You can find the changelog here: CHANGELOG.md

bschnurr avatar Aug 11 '22 21:08 bschnurr

It seems like the bug isn't fixed. Renaming the variable only changes instances in that cell.

VS Code version: 1.71 OS version: Windows 11 22622.586 x64 Restricted Mode: No Python: 3.8.10 Python extension: v2022.15.12441015 Pylance extension: v2022.8.51 Jupyter extension: v2022.9.1002461039

ted1030 avatar Sep 02 '22 03:09 ted1030

@ted1030, when you see rename fail, are you working in an Untitled notebook that you created via the Create: New Jupyter Notebook command? See https://github.com/microsoft/pylance-release/issues/3276

If not, can you please open a new issue explaining what you are seeing? Thanks!

debonte avatar Sep 03 '22 00:09 debonte

I didn't see any failure message. I opened a new issue #3279.

ted1030 avatar Sep 03 '22 06:09 ted1030