Skip to content

Comments

Ignore stray textDocument/didSave requests#712

Closed
mmyrte wants to merge 4 commits intoREditorSupport:masterfrom
mmyrte:avoid-didSave-foreign-language
Closed

Ignore stray textDocument/didSave requests#712
mmyrte wants to merge 4 commits intoREditorSupport:masterfrom
mmyrte:avoid-didSave-foreign-language

Conversation

@mmyrte
Copy link

@mmyrte mmyrte commented Feb 19, 2026

Zed chose to interpret the LSP spec differently from VS Code, sending didSave to any file, not caring what the languageId is - see ocsmit/zed-r#6 - which leads to languagserver trying to parse and lint all over the place. (edit: found #681 also relates to this issue).

Dirk Bäumer tentatively specifies that a server should not respond to a request if the file was not previously opened by it, see microsoft/language-server-protocol#2110, see hudson-trading/slang-server#237 for a sample implementation.

I'm proposing to simply ignore documents that are not yet in the workspace, which fixes the problems on my end. I'm afraid I don't know enough about this package or the protocol to assess whether this is acceptable; I also don't have the time to go into this much further

I am happy to amend this PR, if needed: we could specifically retrieve the document associated with a URI to check for the is_open flag, but that leaves open the question of whether/how to ignore files not yet in the workspace.

@JonGretar
Copy link

Thank you.

Copy link

@rgbkrk rgbkrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'm not a maintainer here obviously but I would love to have this fix.

renkun-ken
renkun-ken previously approved these changes Feb 20, 2026
Copy link
Member

@renkun-ken renkun-ken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@renkun-ken
Copy link
Member

Looks like the change breaks most test cases where each test code relies on did_save to open and parse the supplied document.

@renkun-ken renkun-ken dismissed their stale review February 20, 2026 04:15

Testing should be fixed

@mmyrte
Copy link
Author

mmyrte commented Feb 20, 2026

So I basically called the "more correct" did_open where did_save was previously used as a sort of catch-all. I preserved the did_save where the intention of the test is to e.g. remove a definition from a document.

There are still a couple of errors that apparently existed before I forked, but are fixed by #711.

@renkun-ken
Copy link
Member

#711 has just been merged. @mmyrte Would you like to make this PR based on latest master branch?

Copy link
Member

@renkun-ken renkun-ken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks!

@renkun-ken
Copy link
Member

Closed via #714

@renkun-ken renkun-ken closed this Feb 21, 2026
@mmyrte
Copy link
Author

mmyrte commented Feb 22, 2026

Thanks! Was offline for some hours - glad you could move ahead.

@mmyrte mmyrte deleted the avoid-didSave-foreign-language branch February 22, 2026 06:35
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.

4 participants