-
Notifications
You must be signed in to change notification settings - Fork 126
Add new command for positron.executeCodeInConsole to be used by extensions that handles uri, position, next position
#10580
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
base: main
Are you sure you want to change the base?
Conversation
… that uses vscode.URI and vscode.Position types
|
E2E Tests 🚀 |
| ), | ||
| // -- execute code in console | ||
| new ApiCommand( | ||
| 'positron.executeCodeInConsole', '_executeCodeInConsole', 'Execute code in the Positron console.', |
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.
The reason we need a new command over here is to use the type converters for position, to get the position type that extensions can use.
| // Use the provided position (guaranteed to exist when uri is provided) | ||
| position = opts.position; | ||
| // No editor context when URI is provided | ||
| editor = undefined; |
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're dealing with URIs for the visual editor, and don't want to mess with the editor itself.
| mode: opts.mode, | ||
| errorBehavior: opts.errorBehavior | ||
| }); | ||
| return nextPosition; |
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.
The visual editor needs to know the next position directly, because it manages its own cursor and selection and such.
| * Register the internal command for executing code in console from the extension API. | ||
| * This command is called by the positron.executeCodeInConsole API command. | ||
| */ | ||
| CommandsRegistry.registerCommand('_executeCodeInConsole', async (accessor, ...args: [string, URI, IPosition]) => { |
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 command is registered here so we can make one in extHostApiCommands.ts. I want to note that right now these are not optional arguments for using with this command. Good? Bad? We could do these arguments like URI | undefined if we want.
positron.executeCodeInConsole extensions that handles uri, position, next positionpositron.executeCodeInConsole to be used by extensions that handles uri, position, next position
workbench.action.positronConsole.executeCodein Positron quarto-dev/quarto#867I've been collaborating with @vezwork on how to get more language features hooked up in Quarto's visual editor, and we think this is what we need for the Quarto custom editor interface to be able to send code statement-by-statement to the console. Over in the Quarto extension, we can now do something like:
What we get back is the next position to move the cursor to, in Quarto's case for the virtual doc underlying the visual editor.
It's a little weird to now have two commands, both the old
workbench.action.positronConsole.executeCodeand the newpositron.executeCodeInConsole, but now that we're dealing with positions (and less so, URIs) we need to use the converters that we have access to insrc/vs/workbench/api/common/extHostApiCommands.ts. I think I'd argue they do different enough things that this is OK? Although you can now technically callworkbench.action.positronConsole.executeCodewith a uri and position, but they would have to be the internal main process versions of those; this feels somewhat weird. Is it worth doing more refactoring here to make this nicer?@:sessions
@:console
Release Notes
New Features
positron.executeCodeInConsolefor extensions to execute code for a given language, URI, and position (such as for the Quarto visual editor)Bug Fixes
QA Notes
Once we get changes merged on both the Positron and Quarto sides, you should be able to execute multi-line statements in the console from the visual editor. Once we get further along, I can share more detailed examples