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

Inlay hint location links goto definition goes to the nearest symbol #167564

Closed
HKalbasi opened this issue Nov 29, 2022 · 12 comments · Fixed by #167886 or #169532
Closed

Inlay hint location links goto definition goes to the nearest symbol #167564

HKalbasi opened this issue Nov 29, 2022 · 12 comments · Fixed by #167886 or #169532
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug inlay-hints insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@HKalbasi
Copy link
Contributor

HKalbasi commented Nov 29, 2022

Does this issue occur when all extensions are disabled?: No

  • VS Code Version: 1.73.1
  • OS Version: Pop!_OS 22.04 LTS

Steps to Reproduce:

Recording 2022-11-29 at 19 41 44

It should use the location data which the language server provides if I ctrl+click on the linked part, but instead it runs go to definition for the nearest token (which is colored in addition to the inlay hint part which is under cursor).

@VSCodeTriageBot
Copy link
Collaborator

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.73.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@HKalbasi
Copy link
Contributor Author

It remains.

@HKalbasi
Copy link
Contributor Author

cc #129528 @jrieken

@jrieken jrieken added the ~info-needed Issue requires more information from poster (with bot comment) label Nov 30, 2022
@VSCodeTriageBot
Copy link
Collaborator

Thanks for creating this issue! We figured it's missing some basic information or in some other way doesn't follow our issue reporting guidelines. Please take the time to review these and update the issue.

Happy Coding!

@VSCodeTriageBot VSCodeTriageBot added info-needed Issue requires more information from poster and removed ~info-needed Issue requires more information from poster (with bot comment) labels Nov 30, 2022
@HKalbasi
Copy link
Contributor Author

Steps to reproduce:

  1. Use a language server that supports location links in inlay hints
  2. Ctrl+click on one of the links

It will go to the definition of nearest token (the default behaviour of clicking on inlay hints) instead of the link target. It also should not make the nearest token blue and only blue the link part.

@HKalbasi
Copy link
Contributor Author

Please tell me if there is anything else missing.

@HKalbasi
Copy link
Contributor Author

I can reproduce it in monaco playground as well with this code:

monaco.languages.register({
	id: 'myLang'
});

monaco.editor.create(document.getElementById('container'), {
	value: `
tokenWithNoDefinition
tokenWithDefinition

targetOfToken
targetOfInlayHint
    `,
	language: 'myLang',
	colorDecorators: true
});

monaco.languages.registerDefinitionProvider('myLang', {
    provideDefinition: (model, position) => {
        if (position.lineNumber === 3) {
            return {
                range: new monaco.Range(5, 1, 5, 14),
                uri: model.uri,
            };
        }
    },
});

const inlayLabel = (model) => [
    {
        label: 'Unlinked<',
    },
    {
        label: 'linked',
        location: {
            range: new monaco.Range(6, 1, 6, 14),
            uri: model.uri,
        }
    },
    {
        label: '>Unlinked2',
    },
];

monaco.languages.registerInlayHintsProvider('myLang', {
    provideInlayHints: (model) => {
        return {
            hints: [
                {
                    label: inlayLabel(model),
                    position: new monaco.Position(2, 22),
                },
                {
                    label: inlayLabel(model),
                    position: new monaco.Position(3, 20),
                },
            ]
        };
    },
});

It creates two inlay hints but ctrl+click on either of them won't go to the targetOfInlayHint.

@jrieken jrieken added inlay-hints and removed info-needed Issue requires more information from poster labels Nov 30, 2022
@jrieken
Copy link
Member

jrieken commented Nov 30, 2022

Thanks. Code sample is the way to go 👏

@jrieken jrieken added this to the December 2022 milestone Dec 2, 2022
@jrieken jrieken added the bug Issue identified by VS Code Team member as probable bug label Dec 5, 2022
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Dec 15, 2022
@HKalbasi
Copy link
Contributor Author

@jrieken Can you please reopen this issue? It is not fixed completely yet (#167886 (comment))

@jrieken
Copy link
Member

jrieken commented Dec 19, 2022

Thanks for the ping. I didn't really test this. I have #169532 up for this. It should reduce confusing and make this less error prone

@HKalbasi
Copy link
Contributor Author

Thanks! this now works correctly.

bors added a commit to rust-lang/rust-analyzer that referenced this issue Dec 21, 2022
Implement location link for type inlay hints

fix #11701

This actually doesn't work due a problem in vscode: microsoft/vscode#167564
@dbaeumer
Copy link
Member

Marking as verified due to previous comment.

@dbaeumer dbaeumer added the verified Verification succeeded label Jan 26, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug inlay-hints insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
4 participants