Skip to content

Add setting to turn inlay hints (inferred variable types) on or off #1512

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

Open
rbenegal opened this issue Apr 22, 2025 · 2 comments
Open

Add setting to turn inlay hints (inferred variable types) on or off #1512

rbenegal opened this issue Apr 22, 2025 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@rbenegal
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Currently the default behaviour of the extension is to turn on inlay hints. This adds inferred types with grey text, and the user can double click on the text to insert it into the code. For example the inlay hint for the Package variable type:

Image

While many users like this feature, some may not appreciate it as much and feel like it affects the readability of the code. Additionally, they may not know where this text is coming from if they are new and what they should do to turn it on/off.

Describe the solution you'd like
We should add a setting to turn inlay hints on and off. For now we can turn it off by default and when we add a walkthrough mode we should give the user the option to turn inlay hints on or off by default for swift projects. As well, we can update the documentation to tell users how to turn this feature on/off.

Describe alternatives you've considered
It is possible to turn off inlay hints on or off for swift with the following setting in the settings.json file:

    "[swift]": {
        "editor.inlayHints.enabled": "off"
    },

But users may not know that the inferred types are coming from "inlay hints".

Additional context
We can possibly add a setting that will modify the settings.json to set the right editor.inlayHints.enabled values.

@adam-fowler
Copy link
Contributor

There is already a setting, it just isn't in the Swift settings. Search the settings for inlay hints.

@rbenegal
Copy link
Contributor Author

Thank you! Yes, can definitely turn off inlay hints through the global settings as well (which would set "editor.inlayHints.enabled": "off" globally or for settings.json if done for the workspace I believe) but was thinking the Swift specific setting would be good when the extension is run for the first time and there is some sort of a walkthrough mode to help users configure preferences. New users may not know the setting name to search for and they could be new to VS Code in general as well.

Possibly inlay hints should have been called "variable type hints" or "variable type suggestions" or something to make it easier to find. Also instead of just "Double-click to insert" on hover perhaps it could say "Double-click to insert inlay hint" or show a link to the setting to hide it, but I'm not sure if that text can be overwritten.

rbenegal added a commit to rbenegal/vscode-swift that referenced this issue Apr 28, 2025
Add an extension setting that controls `[swift]` inlay hints so that
hints can be disabled by default for now. Most other language extensions
have inlay hints turned off by default, likely because it is tricky to
figure out how to turn them off/on otherwise.

Later on, when there is a walkthrough mode, we can provide users with
an option to set inlay hints on or off when the extension runs for the
first time.

Issue: swiftlang#1512
@award999 award999 moved this from Unscreened to In Progress in Swift Extension for Visual Studio Code Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants