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_format_document breaks formatting when executed right after editing code #2578

Open
MrFoxPro opened this issue Dec 11, 2024 · 2 comments
Labels

Comments

@MrFoxPro
Copy link

MrFoxPro commented Dec 11, 2024

lsp_format_document.mp4

Seems like server is not fast enough to parse document after change and applies formatting to old version?

Environment:

  • OS: Arch Linux 6.12.1
  • Sublime Text version: 4180
  • LSP version: 2.2.0, 2.3.0
  • Language servers used: vstls, also tried LSP-typescript package
@jwortmann
Copy link
Member

Seems like server is not fast enough to parse document after change and applies formatting to old version?

I'd say this looks more like textDocument/formatting is accidentally sent before textDocument/didChange (the didChange notification is debounced by 300 ms), so I think the server is doing the right thing. We should probably call purge_changes for the SessionBuffer before running the formatting request in

class LspFormatDocumentCommand(LspTextCommand):

and in
class LspFormatDocumentRangeCommand(LspTextCommand):

Next time ideally also post a copy of the logs directly, that would be easier than trying to read the logs from the video :)

@rchl
Copy link
Member

rchl commented Dec 11, 2024

Yes. I came to the same conclusion on discord where it was reported first

@jwortmann jwortmann added the bug label Dec 19, 2024
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

3 participants