Skip to content
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

Remove the toggleInlayHints command from VSCode #13215

Merged
merged 1 commit into from
Sep 12, 2022

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Sep 10, 2022

Inlay hints are no longer something specifc to r-a as it has been upstreamed into the LSP, we don't have a reason to give the config for this feature special treatment in regards to toggling. There are plenty of other options out there in the VSCode marketplace to create toggle commands/hotkeys for configurations in general which I believe we should nudge people towards instead.

Inlay hints are no longer something specifc to r-a as it has been
upstreamed into the LSP, we don't have a reason to give the config
for this feature special treatment in regards to toggling. There are
plenty of other options out there in the VSCode marketplace to create
toggle commands/hotkeys for configurations in general which I believe
we should nudge people towards instead.
@Veykril
Copy link
Member Author

Veykril commented Sep 10, 2022

cc #13144 #6316

@Veykril
Copy link
Member Author

Veykril commented Sep 12, 2022

@bors r+

For the people that used this command, https://marketplace.visualstudio.com/items?itemName=rebornix.toggle allows you to redefine it

@bors
Copy link
Contributor

bors commented Sep 12, 2022

📌 Commit 9c97997 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Sep 12, 2022

⌛ Testing commit 9c97997 with merge b54d22d...

@bors
Copy link
Contributor

bors commented Sep 12, 2022

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing b54d22d to master...

@bors bors merged commit b54d22d into rust-lang:master Sep 12, 2022
@Veykril Veykril deleted the toggle-inlay branch September 13, 2022 12:35
bors added a commit that referenced this pull request Sep 19, 2022
Remove reference to Toggle inlay hints

This simply removes the reference to the `Toggle inlay hints` action after its removal in #13215.
In fact, this reference is still visible [in the User Manual here](https://rust-analyzer.github.io/manual.html#inlay-hints).
@eflukx
Copy link

eflukx commented Sep 20, 2022

Install the toggle extension (as mentioned above) and add this (or similar) entry to the keybindings.json config file

{
    "key": "shift+alt+x",
    "command": "toggle",
    "when": "editorTextFocus",
    "args": {
        "id": "toggle_inlay_hints",
        "value": [
            {
                "editor.inlayHints.enabled": "on"
            },
            {
                "editor.inlayHints.enabled": "off"
            }
        ]
    }
}

@jhpratt
Copy link
Member

jhpratt commented Sep 23, 2022

Is anyone aware of a way to keep it in the command palette? I'd prefer not to bind this to a keyboard shortcut. In my opinion, it is unfortunate that this was removed without a clear replacement with equivalent functionality.

@eflukx
Copy link

eflukx commented Sep 24, 2022

Agree with @jhpratt that the removal of this feature is/feels like a regression in my opinion. At least from a usability perspective....

I can relate to the fact that removing this and leveraging a generic mechanism (for configuring inlay hints) leads to better "cleanliness" overall; less non-standard cruft is probably better in many cases... In this case, however, it cost me at least half an hour figuring out why on earth my keybinding wasn't working anymore. I started my VScode to write some code, but instead needed to fiddle with some new 'toggle' extension and creating the right keybindings.json config to go with it... A less-than-stellar experience.

I'm otherwise very happy with Rust Analyzer, really an amazing project! I'm very grateful to have such fantastic tooling! 🤗 But these UX-annoyances probably could do with some more overthinking for a users perspective...

@Veykril
Copy link
Member Author

Veykril commented Sep 24, 2022

Yes, I can see the problems arising from this, I am sorry for the time waste this may have caused, I assumed VSCode would notify the user if a keybind invokes a command that does not exist. Also, I did not think of the fact that this only has a replacement for the hotkey either. That is, the command can't be re-added in a customizable way because VSCode like usual is way too rigid it seems. I should've done more research here, so again I apologize.

I still feel strongly about not having this be part of r-a, for one as outlined in the PR description, this is absolutely not a r-a specific feature, and I'd like the client to write to the user configuration as little as possible, especially non r-a configurations.

Now, the hotkey binding does have a replacement (as I have linked one), but the issue of now not having a command to manually call I am not sure what to do about. VSCode doesn't allow to create user facing commands on the fly (they have to be predefined by extensions), so a general purpose solution like the linked hotkey extension is not possible ... I'll have to think about this a bit if there is a replacement for that in some form (aside from making a simple extension that just exposes this one feature).

@selendym
Copy link

selendym commented Sep 26, 2022

For those of us who care about not installing some random closed-source extensions, the suggested "solution" is a no-go, unfortunately. Hopefully a better solution will be available at some point, but until then, this commit effectively removed inline hints for me, since having them on at all times is way too noisy.

Edit: seems like the best workaround for now would be to add this into settings: "editor.inlayHints.enabled": "offUnlessPressed". The downside is that the keybinding is hardcoded as ctrl+alt...

@eflukx
Copy link

eflukx commented Sep 26, 2022

For those of us who care about not installing some random closed-source extensions, the suggested "solution" is a no-go,

This whole "bind key to toggle some config param"-functionality would be a nice core functionality of VScode IMO... Maybe consider positing this as a feature request on the VScode repo?

@junderw
Copy link

junderw commented Nov 4, 2022

Edit: seems like the best workaround for now would be to add this into settings: "editor.inlayHints.enabled": "offUnlessPressed". The downside is that the keybinding is hardcoded as ctrl+alt...

If you let go of Alt first after pressing Ctrl + Alt it takes focus away from the text, so you have to click the text again to be able to press Ctrl + Alt in order to show the inlay hints again.

This is not a rust-analyzer issue, (should be VSCode issue) but just bringing up another wart on one of the best workarounds we have so far.

@chase-lambert
Copy link

chase-lambert commented Nov 4, 2022

So I just stumbled into this change as well. I am using neovim and coc.nvim which basically tries to mimic VS Code's LSP functionality. Does anyone know how I could get this back? The work-arounds mentioned above seem to be VS Code specific.

Edit for others who stumble on this in the future: You want to set "inlayHint.display": false in your coc-settings.json. Then in your overall config you can set a keyboard shortcut to run :CocCommand document.toggleInlayHint to get back to that sweet hidden by default but available on command functionality some of us need and crave. haha

@GilShoshan94
Copy link

GilShoshan94 commented Nov 17, 2022

Hi, just to let people know that an issue got oppen in vscode to make the setting toggleable built in addition of the current options on, onUnlessPressed, offUnlessPressed and off.

If people can go upvote before December 11, it will move in their backlog.

We need 2 more upvotes at least.

Here the issue: inlay hints toggle option #163201

Thank you !

@Deebster
Copy link

Deebster commented Dec 7, 2022

@GilShoshan94 annoyingly and strangely it was triaged away as "out of scope". I don't really understand that argument.

@GilShoshan94
Copy link

@Deebster I know... It's very frustrating the way the vscode team just dismiss and close issues without discussion...
It's not the first time for me and it happens often.

I can tell you what I ended up doing:

I added the extension Toggle by @rebornix (marketplace, repo).

(I found the repo but I don't like that on the marketplace it appears closed source... I guess you can build it from source and add it mannually if you want.)

Then in you keybindings.json file I added this:

    {
        // "ctrl+space" does the same already....
        "key": "ctrl+i",
        "command": "-editor.action.triggerSuggest"
    },
    {
        // "ctrl+space" does the same already....
        "key": "ctrl+i",
        "command": "-toggleSuggestionDetails"
    },
    {
        "key": "ctrl+i",
        "command": "toggle",
        "when": "editorTextFocus",
        "args": {
            "id": "toggleInlayHints",
            "value": [
                {
                    "editor.inlayHints.enabled": "on"
                },
                {
                    "editor.inlayHints.enabled": "off"
                }
            ]
        }
    },

And now I can toggle the inlayHints with "ctrl+i" (the first two is to unbind from the default keybind, that's why you see the "-" in front of the command field)


I also asked vscode to add this feature (to toggle any setting with keybind) built in microsoft/vscode#166631 but of course they just closed it very quickly....

I am trying to reopen it.

I invite you to take a look at this feature request and leave there a comment too fo the vscode team to get it reopen.

Have a nice day.

@ksandvik
Copy link

ksandvik commented Dec 9, 2022

Yes, why was this removed??

@craole-cc
Copy link

// Enables the inlay hints in the editor.
// - on: Inlay hints are enabled
// - onUnlessPressed: Inlay hints are showing by default and hide when holding Ctrl+Alt
// - offUnlessPressed: Inlay hints are hidden by default and show when holding Ctrl+Alt
// - off: Inlay hints are disabled
"editor.inlayHints.enabled": "on",

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.