-
Notifications
You must be signed in to change notification settings - Fork 184
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
Allow plugins to ignore certain views #2410
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,6 +128,12 @@ def disable_config_async(self, config_name: str) -> None: | |
self._config_manager.disable_config(config_name) | ||
|
||
def register_listener_async(self, listener: AbstractViewListener) -> None: | ||
config = self._needed_config(listener.view) | ||
if config: | ||
plugin = get_plugin(config.name) | ||
if plugin and plugin.should_ignore(listener.view): | ||
debug(listener.view, "ignored by plugin", plugin.__name__) | ||
return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if this part specifically but it can get into an infinite loop of starting and closing the server. I think when the first opened file is ignored. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have an example where you have seen such an infinite loop? It seems to work as expected on my side, even when the first opened file is ignored. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to be a bit random. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could reproduce it with multiple sessions. This code was indeed misplaced here, because it would disable the listener entirely if any of the applicable sessions ignores the view. I don't know why this did lead to the infinite starting loop, but it's somewhat difficult to understand (for me) what exactly happens in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still see this problem. After adding this to LSP-pyright: @classmethod
def should_ignore(cls, view: sublime.View) -> bool:
return True None of the sessions are starting anymore on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seemed to work randomly for me, sometimes it worked and sometimes it didn't. Could you try again with the latest changes? |
||
set_diagnostics_count(listener.view, self.total_error_count, self.total_warning_count) | ||
# Update workspace folders in case the user have changed those since window was created. | ||
# There is no currently no notification in ST that would notify about folder changes. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is the best place here for this check, because the
can_handle
methods sounds like it might be called more often than necessary. Though the only other reference is inWindowManager.sessions
, but that seems to be an unused method (?)