Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load rope_autoimport cache on workspace/didChangeConfiguration #461

Conversation

tkrabel-db
Copy link
Contributor

@tkrabel-db tkrabel-db commented Oct 13, 2023

Fixes #460

How is this tested?

Manually, ensuring that autoimports works after sending a workspace/didChangeConfiguration to the backend.

image

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestion for you @tkrabel-db, the rest looks good to me.

pylsp/plugins/rope_autoimport.py Outdated Show resolved Hide resolved
@ccordoba12 ccordoba12 added this to the v1.9.0 milestone Oct 13, 2023
@ccordoba12 ccordoba12 added the enhancement New feature or request label Oct 13, 2023
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tkrabel-db!

@ccordoba12 ccordoba12 merged commit 6ff9aa9 into python-lsp:develop Oct 13, 2023
10 checks passed
Comment on lines +245 to +252
"""
Initialize autoimport if it has been enabled through a
workspace/didChangeConfiguration message from the frontend.

Generates the cache for local and global items.
"""
if config.plugin_settings("rope_autoimport").get("enabled", False):
_reload_cache(config, workspace)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could keep the last enabled state and only reload cache on setting actually changing. Otherwise it can trigger wasteful reloads on any other setting changing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a good very idea, thanks @rchl!

@tkrabel-db, what do you think? We could use a global variable to track the plugin's enabled state and only reload the cache when changing from ENABLED = False to True.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do that!

staticf0x pushed a commit to staticf0x/python-lsp-server that referenced this pull request Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rope_autoimport doesn't initialize after workspace/didChangeConfiguration message
3 participants