X Tutup
Skip to content

LSP: Rework management of client owned files#105236

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
HolonProduction:lsp-sync
Dec 17, 2025
Merged

LSP: Rework management of client owned files#105236
Repiteo merged 1 commit intogodotengine:masterfrom
HolonProduction:lsp-sync

Conversation

@HolonProduction
Copy link
Member

@HolonProduction HolonProduction commented Apr 10, 2025

Related to godotengine/godot-vscode-plugin#842 (there is at least one other issue that makes the resolve not work).
Fixes GDQuest/zed-gdscript#6

Supersedes partially #103186 (this PR includes saveguards for all methods except willSaveWaitUntil and didSave which might still do weird stuff when editing non gdscript files).

Our current approach for managing client owned content is as follows:

  • when the client sends changes we parse them and cache them
  • when we are interested in a file we look in the cache, if we don't have it we load it from disk

The catch: scripts with errors are cached differently, so if the client sends a change with parse errors it does not get cached correctly and subsequent requests (such as resolve) might reload the file from disk. Then the content that the server uses might not match with position information from the client which will result in early returns from the resolve endpoint.

This PR splits this solution up, by tracking client owned files separately from the parser cache (this is also relevant for #103186).

It also moves those caches to be per client, to prevent issues when multiple clients are connected.

Known issues:

TODO:

@AThousandShips AThousandShips added this to the 4.5 milestone Apr 10, 2025
@HolonProduction HolonProduction force-pushed the lsp-sync branch 3 times, most recently from bbe01d9 to 96cca19 Compare June 22, 2025 16:28
@HolonProduction HolonProduction modified the milestones: 4.5, 4.6 Jun 22, 2025
@HolonProduction HolonProduction force-pushed the lsp-sync branch 6 times, most recently from 4c10b2b to a2d3012 Compare June 25, 2025 14:54
@HolonProduction HolonProduction force-pushed the lsp-sync branch 2 times, most recently from 5186a9f to fd71dda Compare September 20, 2025 00:12
@HolonProduction HolonProduction marked this pull request as ready for review September 20, 2025 00:12
@HolonProduction HolonProduction requested review from a team as code owners September 20, 2025 00:12
@HolonProduction
Copy link
Member Author

Rebased after #111684

This PR effectively reverts the changes to TextDocumentItem made there, since with this PR the struct is no longer used for TextDocumentIdentifier loading, which means the field are always required by the LSP spec.

@fstxz
Copy link
Contributor

fstxz commented Oct 27, 2025

I tested locally with Zed and it seems to work as expected, I am no longer getting errors when editing non-gdscript files.

@atirutw
Copy link
Contributor

atirutw commented Dec 10, 2025

Any chance this will make it into 4.6?

@akien-mga
Copy link
Member

@van800 Would you be able to test this against Rider to confirm that it doesn't introduce regressions?

@van800
Copy link
Contributor

van800 commented Dec 10, 2025

Sure, I will try within today-tomorrow.

@van800
Copy link
Contributor

van800 commented Dec 10, 2025

At the moment Rider doesn't send anything about non-gd files.
I haven't spotted any problems while working with Godot from this pull request.

It would be interesting to know what the benefits of tracking the metadata of non-gd files are. Do any document links like gd-tscn work in Zed?

@HolonProduction
Copy link
Member Author

It would be interesting to know what the benefits of tracking the metadata of non-gd files are. Do any document links like gd-tscn work in Zed?

Zed does no client side filtering and sends lifecycle messages for all files to the server. So we need to filter for GDScript on the server side. Keeping track of the metadata is necessary for that. Because the language id associated with a file only gets send when it is first opened.

If we would just discard all non gdscript metadata and later receive some change notification for e.g. a scene file. It would not be clear whether the file is no GDScript or the client is broken (the VSCode extension used to send change requests without opening documents properly).

@van800
Copy link
Contributor

van800 commented Dec 11, 2025

If it just satisfies Zed, why shouldn't it be fixed there?

That said, I confirm, I haven't found any regressions introduced by this pull request.

I have made a ticket for myself to update languageId in Rider to "gdscript" to be aligned with other lsp clients. In this PR the case is handled nicely.

@HolonProduction
Copy link
Member Author

If it just satisfies Zed, why shouldn't it be fixed there?

Zed plugins can't do that and the conversation in zed-industries/zed#37813 does not sound as if Zed would filter for relevant files anytime soon.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Rationale makes sense to me. I haven't reviewed the code in depth but I trust Holon on that as the LSP maintainer.

@Repiteo Repiteo merged commit d9f9387 into godotengine:master Dec 17, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 17, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GDScript errors are reported in other filetypes (e.g. .rs files)

7 participants

X Tutup