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

Properly handle disabling of the LSP package #2085

Merged
merged 21 commits into from
Oct 21, 2022
Merged

Properly handle disabling of the LSP package #2085

merged 21 commits into from
Oct 21, 2022

Conversation

rchl
Copy link
Member

@rchl rchl commented Oct 11, 2022

Trying to better handle cleanup on disabling the LSP package and kill some leaks:

  • Change WindowRegistry.lookup return value from WindowManager to Optional[WindowManager]. This ensures that when the LSP package gets disabled, existing references doing a lookup won't be able to create new instances of WindowManager.
  • Ensure various functions in panel.py go through WindowManager when wanting to create output panel for Window so that they don't create panels when package is disabled.
  • Don't unload global settings (globalprefs) on plugin_unloaded as that can cause crashes in code that is still running
  • Create dummy userpref on plugin_unloaded so that accessing settings doesn't crash
  • Remove ConfigManager and make WindowRegistry responsible for creating WindowConfigManagers and passing it to WindowManager.
  • Do something about configs and (?) client_configs globals. Maybe those should live and be controlled through WindowRegistry so that we have least amount of globals possible.

Note that due to ST bug sublimehq/sublime_text#5148, we don't currently remove and delete instances of WindowManager so added a workaround for that so that we remove no longer valid instances now and then. The bug was fixed.

Should fix #2082 when completed.

@rchl rchl marked this pull request as ready for review October 18, 2022 19:34
@rchl
Copy link
Member Author

rchl commented Oct 18, 2022

For now I'm done. I did some refactorings that should make it behave better when package is disabled/unloaded. Don't think everything is perfect yet but it should be getting there.

I realize the changes are hard to review so one might rely on tests more here. :)

@rchl
Copy link
Member Author

rchl commented Oct 18, 2022

Actually I've just tested disabling the LSP package and it didn't really address the issue with panels not being destroyed. Or, they are destroyed but due to async nature they come back immediately when remaining requests are being handled. Since now all panels are controlled through the same path (PanelManager) it's easier to prevent that but I'm a bit hesitant to add many repetitive checks...

EDIT: addressed in later commit

@rchl
Copy link
Member Author

rchl commented Oct 21, 2022

Think nobody wants to waste their life reviewing it properly so life will review it.

@rchl rchl merged commit 4332c98 into main Oct 21, 2022
@rchl rchl deleted the fix/windows-global branch October 21, 2022 19:30
@predragnikolic
Copy link
Member

Think nobody wants to waste their life reviewing it properly so life will review it.

pretty much like the code changes in this PR but haven't tested it :)

rchl added a commit that referenced this pull request Jan 16, 2023
* main:
  Focus symbol closest to selection on showing document symbols
  Properly handle disabling of the LSP package (#2085)
  fix issues with restarting servers (#2088)
  Add `$line` and `$character` expansion variables (#2092)
  Only enable Goto Diagnostic commands if diagnostic with configured severity exists (#2091)
  Update diagnostics gutter icons and change default to "sign" (#2086)
  Fix short color box rendering bug after color presentation change (#2087)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Output panels are not (reliably) destroyed if LSP is disabled
2 participants