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

LSP is never started for initial unsaved buffer #2322

Open
jwortmann opened this issue Sep 11, 2023 · 0 comments
Open

LSP is never started for initial unsaved buffer #2322

jwortmann opened this issue Sep 11, 2023 · 0 comments
Labels

Comments

@jwortmann
Copy link
Member

A small inconvenience that I noticed when you open a fresh instance of Sublime Text and start to type in the initial buffer.
I'm not sure why exactly it happens, maybe it's some timing issue or even a ST bug could be the cause?

To Reproduce

With a language server configured to be active for unsaved buffers, e.g. LSP-pyright with default config "schemes": ["file", "buffer", "res"] ...

Case A:

  1. Start ST
  2. Run Set Syntax: Python from the command palette
  3. Type print('hello')

Case B:

  1. Start ST
  2. Type print('hello')
  3. Run Set Syntax: Python from the command palette

Case C:

  1. Start ST
  2. Ctrl+N (invokes new_file command)
  3. Run Set Syntax: Python from the command palette
  4. Type print('hello')

Expected behavior
Case A: no LSP (ideally only until you select another tab and then the first tab again)1
Case B: LSP started
Case C: LSP started

Actual behavior
Case A: no LSP (even after you select another tab and then the first tab again!)
Case B: no LSP
Case C: LSP started

Environment (please complete the following information):

  • OS: Windows 11
  • Sublime Text version: 4152
  • LSP version: 663afdc (latest commit at the time of writing this)

Additional context
With debug logging enabled, LSP: couldn't find a text change listener for ViewListener(12) gets printed to the console (twice). But if you add a print statement for debugging into the TextChangeListener.attach method from the plugin/core/documents.py file, you can see that this method does get called even for the initial buffer 🤷

Footnotes

  1. This expectation is with the limitations of the current implementation in mind, i.e. check in DocumentSyncListener.on_activated_async whether to start a language server

@jwortmann jwortmann added the bug label Sep 22, 2023
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

1 participant