microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.72k stars 767 forks source link

"No refactorings available" / "No code actions" when cursor is inside of a string #6343

Closed DamianFekete closed 2 months ago

DamianFekete commented 2 months ago

Type: Bug

Behaviour

No refactorings available / No code actions for 'refactor.extract.variable' available

Steps to reproduce:

def f():
    print("Ohh no")

f()

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

``` XXX ```

Extension version: 2024.12.3 VS Code version: Code 1.92.2 (fee1edb8d6d72a0ddff41e5f71a671c23ed924b9, 2024-08-14T17:29:30.058Z) OS version: Windows_NT x64 10.0.19045 Modes:

User Settings

``` languageServer: "Pylance" ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |Edit csv|janisdd.vscode-edit-csv|0.9.2| |EditorConfig for VS Code|EditorConfig.EditorConfig|0.16.4| |IntelliJ IDEA Keybindings|k--kato.intellij-idea-keybindings|1.7.2| |JavaScript Debugger|ms-vscode.js-debug|1.92.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.3| |PowerShell|ms-vscode.powershell|2024.2.2| |Pylance|ms-python.vscode-pylance|2024.8.2| |Python|ms-python.python|2024.12.3| |Python Debugger|ms-python.debugpy|2024.11.2024082901| |SailPoint Identity Security Cloud|yannick-beot-sp.vscode-sailpoint-identitynow|1.3.2| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.9|
System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz (16 x 2304)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off| |Load (avg)|undefined| |Memory (System)|31.73GB (12.73GB free)| |Process Argv|.| |Screen Reader|no| |VM|0%|

The original bug report against VS Code was closed: https://github.com/microsoft/vscode/issues/225766

rchiodo commented 2 months ago

Thanks for the issue. You have to select the text for this to work (otherwise we don't know what to select to extract).

https://github.com/user-attachments/assets/bbb1f1dd-3d35-4a50-84e6-03784ed38f0a

We could potentially special case strings to auto pick the whole thing, but there's a perf penalty with generating code actions everywhere.

rchiodo commented 2 months ago

Reopening. Going to mark as an enhancement request for upvotes.