-
Notifications
You must be signed in to change notification settings - Fork 1.7k
internal: Do not send inlay hint refresh requests on file edits #15529
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
internal: Do not send inlay hint refresh requests on file edits #15529
Conversation
Does this work if you disable cache priming? It feels a bit weird to have them linked. |
Hmm, actually looking at the code here. The previous logic does makse sense. If proc-macros were rebuilt, build scripts reran or the workspace has changed, anything could've changed in the open buffers so we should ask the client to refresh the hints. I misunderstood and read it as we ask for a refresh on any file change, but that's not what this code path does (if it does hit on every rust source file change thats a bug) |
Editor itself is able to invalidate hints after edits, and /refresh was sent after editor reports changes to the language server. This forces the editor to either query & invalidate the hints twice after every edit, or wait for /refresh to come before querying the hints. Both options are rather useless, so instead, send a request on server startup only: client editors do not know when the server actually starts up, this will help to query the initial hints after editor was open and the server was still starting up.
7e0ee0a
to
62d1897
Compare
Thank you for the pointers, I have a better thought at the code, looks like I've got it better now: the server will send a /refresh hint request when it's quiescent (as before), and any of the previous tasks had either reported a procmacro change, or a The latter is the best event that matches the "load everything and be ready to respond with inlay hints" state I've found after cache priming: this seem to work for editors that query hints after this /refresh. Otherwise, we now do not react on file edits with /refresh, which was my main goal.
Yes, that was the case before my changes. |
So, I think I retract my statement that that's a bug actually. I think I know why we might be doing things the way we are doing right now. Edits in one file can affect the inlay hints and similar in another file if we change a struct name for example. If we no longer send out refreshes I imagine those of the other files will become possibly outdated? |
And what if not an editor is there first to register the edit fact, grab all open buffers' hints caches and invalidate them? 🙂 Let's look from the editor's perspective: it opts into /refresh request with the client capability, and then waits for language servers to respond.
Neither option seems good or bringing any benefits even if implemented, since simply "do nothing and send no /refresh requests" brings exactly the same result with less effort? But I might miss something, hence was asking for more details in the original issue.
Also to note, currently any change, comments included, trigger another /refresh query from r-a. |
Oh don't get me wrong, this is fine if the editors re-request inlay hints for other files after a change in one particular. I was just wondering, given that the refresh request is so not well documented 😅 I am fine with merging this for now it might just work exactly how we want it to 🤞 (and I definitely agree that us sending so much json data unnecessarily is suboptimal). If it causes issues we can reconsider. @bors r+ |
On a different note, wouldn't the same apply to semantic highlighting? 🤔 |
Alas, I'm not aware of anything related to highlighting. |
One day we'll hopefully lint for unresolved paths (unfortunately it is non trivial as path resolution is split across multiple contexts in r-a opposed to rustc (for good reason) 😩) |
☀️ Test successful - checks-actions |
See #13369 (comment)
Editor itself is able to invalidate hints after edits, and /refresh was sent after editor reports changes to the language server. This forces the editor to either query & invalidate the hints twice after every edit, or wait for /refresh to come before querying the hints.
Both options are rather useless, so instead, send a request on server startup only: client editors do not know when the server actually starts up, this will help to query the initial hints after editor was open and the server was still starting up.