-
Notifications
You must be signed in to change notification settings - Fork 36
Remove virtualDocUri()
as a footgun
#713
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 virtualDocUri()
as a footgun
#713
Conversation
await vdocUri.cleanup(); | ||
return await withVirtualDocUri(vdoc, document.uri, "hover", async (uri: Uri) => { | ||
try { | ||
return await getHover(uri, vdoc.language, position); |
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.
We did not await
before but I'm guessing it's probably better to?
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.
I think you are correct on this; I occasionally would observe slight glitchy-ness with the embedded help in Quarto files and I can't get it to happen now with this PR.
await vdocUri.cleanup(); | ||
return await withVirtualDocUri(vdoc, document.uri, "signature", async (uri: Uri) => { | ||
try { | ||
return await getSignatureHelpHover(uri, vdoc.language, position, context.triggerCharacter); |
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.
We did not await
before but I'm guessing it's probably better to?
@@ -280,64 +272,61 @@ function embeddedGoToDefinitionProvider(engine: MarkdownEngine) { | |||
): Promise<Definition | LocationLink[] | null | undefined> => { | |||
const vdoc = await virtualDoc(document, position, engine); | |||
if (vdoc) { | |||
const vdocUri = await virtualDocUri(vdoc, document.uri, "definition"); |
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.
This diff looks ugly but I didn't change anything in the try
or catch
block. It's just switching to withVirtualDocUri()
and removing the finally
block
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.
Thank you for working on this! Super happy to see those virtualDocUri
uses cleaned up 🙌
await vdocUri.cleanup(); | ||
return await withVirtualDocUri(vdoc, document.uri, "hover", async (uri: Uri) => { | ||
try { | ||
return await getHover(uri, vdoc.language, position); |
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.
I think you are correct on this; I occasionally would observe slight glitchy-ness with the embedded help in Quarto files and I can't get it to happen now with this PR.
There were 3 remaining places where we used
virtualDocUri()
instead ofwithVirtualDocUri()
. The ad hoc usage of this is scary because it requires us to carefully analyze the call to ensure we call thecleanup()
hook (#708).withVirtualDocUri()
always handles this, so this PR removesvirtualDocUri()
as a footgun altogether by routing everything throughwithVirtualDocUri()
and then unexportingvirtualDocUri()
.