-
Notifications
You must be signed in to change notification settings - Fork 107
Support functions in View()
#8262
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
Conversation
E2E Tests 🚀 |
}); | ||
const documentData = await this.documents.ensureDocumentData(uri); |
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 is just a small cleanup to use await
syntax that I did while I was planning to do more changes here. I didn't end up modifying this handler, but I thought we might keep the cleanup. It causes the handler to only resolve when showTextDocument()
has resolved, which I think is probably best in terms of assumptions made by the requester.
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.
Tested with ark changes & things work well!
return await this._client.sendRequest(VIRTUAL_DOCUMENT_REQUEST_TYPE, params, token); | ||
} catch (err) { | ||
LOGGER.warn(`Failed to provide document for URI '${uri}': ${err}`); | ||
return 'Error: This document does not exist'; |
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.
What do you think about including the URI and error in the document body, or showing it in a notification, so it's easier to diagnose without digging into logs?
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 thought about that but I worried about making this less user friendly. The main question is whether this should be considered a regular UI message or an exceptional one that warrants presenting debug info to the user.
It would probably be fine to do the latter for now, but if we ever have vdocs representing transient objects with good lifecycle management (vdoc goes out of scope with the object they represent), then this error message would be a normal part of the user experience.
I plan to reuse this mechanism for the fallback vdocs of the debugger. Currently they are managed via DAP and a big downside is that the names of these editors don't have a .R
extension and Positron doesn't activate R language support in these editors. By using ark:
URIs pointing to documents fully managed by Ark, we'll have better control. Unlike the documents created by View()
, these documents will be cleaned up, when the debugging session ends. So users might start seeing this message more regularly (not entirely sure, maybe that will only be the case if we notify the frontend provider that the document has been updated).
543d63c
to
9e4e5b1
Compare
In case it's not managed by a comm
7514a39
to
6264530
Compare
Addresses #2945.
Companion PR for posit-dev/ark#848.
The main change needed on the frontend side is to detect non-file schemes in the
OpenEditor
event handler of the UI comm. This way we preserveark:
URIs, which allows Ark to request the frontend to open documents via its own vdoc provider.I also improved vdoc provider errors to be more user friendly. The error is mentioned in the virtual editor and the error message is logged.
Release Notes
New Features
View()
now supports function objects (Ark:View()
should support function objects #2945). It takes you directly to the original source, if the function has source references, or to a virtual document containing the deparsed function code otherwise.Functions are now also viewable from the Variables pane. Click on the "view" button on the right hand side of a variable entry to view its source definition in an editor.
Bug Fixes
QA Notes
See companion PR: posit-dev/ark#848.
@:variables