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

Wrong SessionView destroyed on restarting session #2258

Open
rchl opened this issue May 15, 2023 · 3 comments
Open

Wrong SessionView destroyed on restarting session #2258

rchl opened this issue May 15, 2023 · 3 comments
Labels

Comments

@rchl
Copy link
Member

rchl commented May 15, 2023

Describe the bug

I've noticed that triggering "Restart server" on a file with active LSP-rust-analyzer session typically results in didClose being sent to the newly created session which is probably also the reason that inlay hints don't always show up properly after such action.

It looks like the culprit is the code that triggers after old session was destroyed but after new session has already started. This then destroys SessionView based on config name which obviously is not a good key for differentiating two instances of the Session for the same server.

LSP/plugin/documents.py

Lines 222 to 228 in 346599a

def on_session_shutdown_async(self, session: Session) -> None:
removed_session = self._session_views.pop(session.config.name, None)
if removed_session:
removed_session.on_before_remove()
if not self._session_views:
self.view.settings().erase("lsp_active")
self._registered = False

To Reproduce

  1. Install LSP-rust-analyzer
  2. Open some *.rs file
  3. LSP: Restart session
  4. Watch the logs

Environment (please complete the following information):

  • Sublime Text version: 4150
  • LSP version: latest commit as of now
@rchl rchl added the bug label Jun 2, 2023
@rchl
Copy link
Member Author

rchl commented Jun 2, 2023

Also this can result in auto complete triggers being removed from view settings due to those being out of order:

SessionView._clear_auto_complete_triggers
SessionView._clear_auto_complete_triggers
SessionView._setup_auto_complete_triggers
SessionView._clear_auto_complete_triggers

@jwortmann
Copy link
Member

I think this is also the cause for infinite initialize -> exit loops when you move a tab between windows and if it was the last tab of the session (doesn't happen all the time, but more often than not).

@rchl
Copy link
Member Author

rchl commented Jun 3, 2023

Two ways of addressing this come to mind:

  1. ensure that only one instance of given config is running at the time (fully shut down one before starting another one)
  2. have unique/random IDs for each session

In the second case, we'd still have to use config name for at least auto complete triggers settings since on restarting ST we need to be able to lookup existing settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants