-
Notifications
You must be signed in to change notification settings - Fork 2
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
[WIP] Use inlay hints to render captures #34
base: master
Are you sure you want to change the base?
Conversation
src/extension.ts
Outdated
const result = await client.sendRequest(ExecuteCommandRequest.type, { | ||
command: "inferredCaptures", | ||
arguments: [{ uri: document.uri.toString() }] | ||
}) as { location: vscode.Location, captureText: string }[]; | ||
|
||
log("Inlay hints result: " + JSON.stringify(result)); | ||
|
||
if (!result) { | ||
log("No results returned."); | ||
return hints; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes the backend just returns null
, no idea why.
Sometimes it's a bit much to see them. What's the expected UX? Should we even show empty captures? |
// Truncate long captures ourselves. | ||
// TODO: Does this make sense? Shouldn't we at least show the first one? | ||
// TODO: Can the backend send them in a list so that we can have a somewhat stable (alphabetic?) order? | ||
const hintText = response.captureText.length > 30 ? "{…}" : response.captureText; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VSCode actively truncates inlay hints that are too long (something like 34 chars?), therefore it's better that we try to truncate ourselves. We can bike shed the proper constant here, but should we show at least some captures like {async, io, Exception, ...}
or should we just go to {...}
in such a case (and rely only on the hover like in the screenshot above?)
Very WIP, but here are a few screenshots:
A short-term goal is to retire the current hacky implementation of rendering inferred captures (by using inlay hints instead).
A long-term goal would be to use inlay hints as a proper mechanism on the server side (relevant to effekt-lang/effekt#524)
Resolves #32 (mostly by accident)
Current issues / TODOs:
inferredCaptures
API works, sometimes it's weirdly invalidated? (If I figure out what I should want, we could even change the Effekt compiler here...)showCaptures
, add to docs that one needs to enable inlay hints in the editor globally (as a feature)holes
code can also be replaced by this perhaps? (probably not though)