-
Notifications
You must be signed in to change notification settings - Fork 44
Force a user save on untitled documents, before switch to visual mode #831
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
|
For more background on why we have a special command in Positron for this kind of switch, see #684 |
|
Thanks for adding a period for my #823 changelog note :) |
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 locally and this PR addresses the problem in Positron, as described by #827
I did notice that the problem remains in VSCode. Added a suggested fix for it.
| // save then close | ||
| await commands.executeCommand("workbench.action.files.save"); | ||
| await commands.executeCommand('workbench.action.closeActiveEditor'); | ||
| VisualEditorProvider.recordPendingSwitchToVisual(document); | ||
| // open in visual mode | ||
| await commands.executeCommand("vscode.openWith", | ||
| document.uri, | ||
| VisualEditorProvider.viewType, | ||
| { | ||
| viewColumn | ||
| } | ||
| ); | ||
| } |
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.
| workspace.onDidSaveTextDocument(async (doc: TextDocument) => { | |
| VisualEditorProvider.recordPendingSwitchToVisual(doc); | |
| // open in visual mode | |
| await commands.executeCommand('workbench.action.closeActiveEditor'); | |
| await commands.executeCommand("vscode.openWith", | |
| doc.uri, | |
| VisualEditorProvider.viewType, | |
| { viewColumn } | |
| ); | |
| }); | |
| // save then close | |
| await commands.executeCommand("workbench.action.files.save") |
Here's a fix for VSCode.
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 I accidentally didn't remove the old code in the suggested change.
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.
@juliasilge I can push this fix for VSCode to the branch if it looks good.
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.
Yes, that would be great! Feel free to push an additional fix.
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.
@juliasilge pushed.
|
Oh, I seem to have lost my insert edit: made a PR to make that config part of the repo #837 |
Addresses #827
Untitled files cannot be edited in visual mode; we actually have a whole special set of screens to show people about this:
https://github.com/search?q=repo%3Aquarto-dev%2Fquarto%20untitled_document_cannot_be_edited&type=code
The new Positron-specific command we made to help with these switches
positron.reopenWithis working generally well, but it doesn't know about this special Quarto rule. If we have an untitled document here, let's force the user to save before switching.