microsoft / microsoft/language-server-protocol

Clarify expected use for inlayHint/refresh

Open
#1,546 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request inlay hint
Dominant language
TypeScript
Stars
13k
Forks
1k
Avg merge
6d 1h
Merged PRs (30d)
10

Description

I'm implementing InlayHints and noticed an issue with them not refreshing in VS Code when I need them to.

file1

final foo = getThing();

file2

String getThing() {}

If I enable inlay hints, file1 gets a String hint on foo to show that the inferred type is Foo.

However, if I modify file2 and change String to int, VS Code does not know to refresh the labels in file1 (I have both files open side-by-side).

It seems like the answer to this is to call inlayHint/refresh, however:

  • It doesn't take a filename, so will refresh them for every single file
  • Doing this essentially on every file modification sounds like it could result in a lot of additional requests
  • The spec makes it sound like we shouldn't be calling this often:
       * Note that this event is global and will force the client to refresh all
       * inlay hints currently shown. It should be used with absolute care and
       * is useful for situation where a server for example detects a project wide
       * change that requires such a calculation.
    

How is this intended to work? What are the responsibilities of the client, and what are the responsibilities of the server to ensure these labels are kept up-to-date when they reference functions from other files?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the inlayHint/refresh specification and the cross-file example in this issue. Resolve the intended responsibilities of the client and server, including the scope and frequency of refresh requests. Done means the protocol guidance clearly explains how labels depending on other files stay up to date.

Written by the indexing model from the issue text.

Assessment

Tech stack
vscode
Domain
api, documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.