-
Notifications
You must be signed in to change notification settings - Fork 30k
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 hints: Allow ctrl/cmd+click to go to a type's definition #129528
Comments
In a similar vein, the hover for the inlays should show for the type they're hovering imo |
I don't know what the plans are for inlay hints, but I think this is doable with injected text. |
@jrieken Adding you since I believe VS Code's inlay hints api would need to be modified to support this |
Yeah, we want that |
Stretch for September |
…ion for each part/node, prep for microsoft/vscode#129528 Commit: f0cc5604d7fd0739bc10c0cc5e956699dc4fbbde
Commit: 1b6e853df16c5289082c63bf391f5ec62479f2ac
…29528 Commit: b61f32323db74cf9e4945431a835ba15190f64e0
Commit: 62bae334d5b12f02ef4078c8114336426de346e0
…icrosoft/vscode#129528 Commit: 5abd7539d142538f56d08b9ea0262ca48853bf19
…n and happens only once, microsoft/vscode#129528 Commit: 1fdcfde34410ca50dcfb3e5a534323eb2d087571
… context menu on right click, microsoft/vscode#129528 Commit: 120718992a05ccf3cf4b90237128e7c561086997
👋 I think this change isn't backwards compatible (at Monaco level): - provideInlayHints(model: model.ITextModel, range: Range, token: CancellationToken): ProviderResult<InlayHint[]>;
+ provideInlayHints(model: model.ITextModel, range: Range, token: CancellationToken): ProviderResult<InlayHintList>; Because you used to return an array of hints, and now you need to return the object with hints (and it crashes if you pass the array ) microsoft/TypeScript-Website#2247 ( I'm happy to make changes to our usage, but would also need to find a way to know which shape of data to provide. ) |
Inlay hints are still proposed API which means breaking changes are happening. Also, there is no stability guarantee wrt API for monaco |
@jrieken I'm reusing the proposed API in rust-analyzer and came up with a small test change: https://github.com/rust-analyzer/rust-analyzer/compare/master...SomeoneToIgnore:kb/vscode-inlay-hints?expand=1 Similar changes worked and displayed the hints on early proposal's stages, but not now: with the I see no errors or warnings in any logs available, ensured that all experimental APIs are enabled and the extension installs and starts normally, so interested, what else have I missed? |
Hard to distance-diagnose... Is the feature enabled? Check the Also, do "F1 > Log Level > Trace" and check the extension host log via "F1 > Show Logs > Extension Host". It should show messages "similar" to these |
The former is on, but the latter does not happen: I see no trace entries in the logs at all. Thanks nonetheless. |
Can you check the trace log of the window for messages like The sample snippet from the video above is this. Notice how it is registered for the vscode.languages.registerInlayHintsProvider('fooLang', new class implements vscode.InlayHintsProvider {
// onDidChangeInlayHints?: vscode.Event<void> | undefined;
provideInlayHints(doc: vscode.TextDocument, range: vscode.Range, _token: vscode.CancellationToken) {
const result: vscode.InlayHint[] = [];
const text = doc.getText();
{
let end = doc.offsetAt(range.end);
let pos = doc.offsetAt(range.start);
while (pos < end) {
const idx = text.indexOf('bar', pos)
if (idx < 0) {
break;
}
pos = idx + 4;
const start = doc.positionAt(idx);
result.push(new vscode.InlayHint(start, [{ value: 'foo' }]))
// result.push(new vscode.InlayHint('FooFooFooFooFooFooFooFooFooFooFooFooFooFooFooFooFooFooFooFooFooFooFooFoo', start))
}
}
{
let end = doc.offsetAt(range.end);
let pos = doc.offsetAt(range.start);
while (pos < end) {
const idx = text.indexOf('foo', pos)
if (idx < 0) {
break;
}
pos = idx + 4;
const start = doc.positionAt(idx + 3);
const label: vscode.InlayHintLabelPart[] = [
{ value: ': ' },
{ value: 'Map' },
{ value: '<number, ' },
{ value: 'typeof document' },
{ value: '' },
{ value: '>' },
]
const hint = new vscode.InlayHint(start, label);
hint.paddingLeft = true;
hint.command = { command: 'extension.helloWorld', title: 'sss' }
result.push(hint)
}
}
return result;
}
async resolveInlayHint(hint: vscode.InlayHint): Promise<vscode.InlayHint> {
await new Promise(resolve => setTimeout(resolve, Math.random() * 1234))
hint.tooltip = new vscode.MarkdownString('I am **Resolved** $(zap)', true);
if (typeof hint.label !== 'string') {
for (let part of hint.label) {
if (part.value === 'Map') {
part.location = new vscode.Location(
vscode.Uri.file('/Users/jrieken/Code/vscode/extensions/node_modules/typescript/lib/lib.es2015.collection.d.ts'),
new vscode.Position(20, 10)
)
part.tooltip = new vscode.MarkdownString('`lib.es2015.collection.ts`', true)
part.command = { command: 'helloWorld', title: 'Hello World', tooltip: 'dddd' }
} else if (part.value === 'typeof document') {
part.location = new vscode.Location(
vscode.Uri.file('/Users/jrieken/Code/vscode/extensions/node_modules/typescript/lib/lib.dom.d.ts'),
new vscode.Position(17160, 13)
)
part.tooltip = new vscode.MarkdownString('`lib.dom.ts`', true)
} else if (part.value === 'foo') {
part.command = {
command: 'helloWorld',
title: 'Hello World',
tooltip: 'dddd'
}
part.tooltip = new vscode.MarkdownString('I am a _label_ *part* $(check)', true)
part.location = new vscode.Location(
vscode.Uri.file('/Users/jrieken/Code/vscode/extensions/node_modules/typescript/lib/lib.es2015.collection.d.ts'),
new vscode.Position(20, 10)
)
}
}
}
// console.log('DONE', hint.label)
return hint;
}
}) |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Oh... That is very interesting and very good drilling 👏 It is likely that position isn't an instance of |
@Tyriar I think that's the default behavior (if you look closely, I believe ctrl+hover actually underlines the var in this case) We haven't actually hooked this up for JS/TS yet but I'll open a TS issue for this |
@mjbvz makes sense, thanks |
Testing #129381
I tried ctrl+clicking
TerminalIcon
here intuitively:Going to an argument definition would also be handy/expected
The text was updated successfully, but these errors were encountered: