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

"No code actions available" if Ctrl+. is hit quickly after moving the cursor

Open ThiefMaster opened this issue 3 years ago • 7 comments

Environment data

  • Language Server version: Pylance language server 2021.4.3 (pyright 320a0a2f)
  • OS and version: Linux
  • Python version: CPython 3.9.4

Expected behaviour

Imports suggested from all stdlib and application packages

Actual behaviour

Imports only suggested for imports coming from files I previously opened in the editor

Remarks

This is a rather large project. Does pylance/pyright switch to lazy analysis at some point? If yes, can this be tuned? Not getting imports generated without me opening (and thus knowing) the file containing them first kind of defeats its purpose...

ThiefMaster avatar May 07 '21 08:05 ThiefMaster

At the moment, this is intended behavior. You can opt-in to workspace/library indexing by enabling the hidden option:

"python.analysis.indexing": true

Can you try it and see if this behaves as you expect?

jakebailey avatar May 07 '21 17:05 jakebailey

That tip was super useful - it made "Go to symbol in workspace" much faster as well (and I was always annoyed by the rather poor performance of that command in a larger project).

The CTRL+Space autocompletion does not suggest it (I'm curious.. why? At least I usually use that first!), but CTRL+. seems to work fine for it now.

However I noticed something strange - probably an unrelated issue though: If I press the shortcut very quickly after moving the cursor to name I want to import, I usually get "No code actions available". If I wait a moment longer, it works fine though.

ThiefMaster avatar May 07 '21 18:05 ThiefMaster

Thanks for the feedback. I think for your completion comment, that's #1055; we're currently working on ways to refine the massive number of completions that indexing produces (so many that it negatively impacts performance), and I think you're hitting that case. Code actions don't have the restriction, as they aren't as "spammy" as completions. Feel free to vote/comment there with your feedback.

I don't think that moving the cursor then clicking should be any different than waiting; this might be a case where we aren't waiting for the info or some other bug. @heejaechang would know better.

jakebailey avatar May 07 '21 18:05 jakebailey

I need to check but I don't think vscode currently has a forced code action like VS. (VS forces code action to run when ctrl+. is issued), you need to wait until vscode gets code action (light bulb to show up) before you can issue ctrl+.

heejaechang avatar May 20 '21 06:05 heejaechang

It does, Ctrl+. does that in VS Code.

jakebailey avatar May 20 '21 16:05 jakebailey

if ctrl+. does force code action, then we probably are not waiting for BG to finish processing everything in the queue before return.

heejaechang avatar Jun 15 '21 17:06 heejaechang

we need to add an ability to wait until every request posted to BG are done when ctrl+. is asked. currently we don't have a way.

heejaechang avatar Apr 12 '22 00:04 heejaechang

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

heejaechang avatar Oct 20 '23 17:10 heejaechang