Skip to content

Conversation

@juliasilge
Copy link
Collaborator

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.reopenWith is 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.

@juliasilge
Copy link
Collaborator Author

For more background on why we have a special command in Positron for this kind of switch, see #684

@juliasilge juliasilge requested a review from vezwork September 29, 2025 23:37
@vezwork
Copy link
Collaborator

vezwork commented Oct 1, 2025

Thanks for adding a period for my #823 changelog note :)

Copy link
Collaborator

@vezwork vezwork left a 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.

Comment on lines 133 to 145
// 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
}
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliasilge pushed.

@juliasilge juliasilge merged commit b15aa38 into main Oct 1, 2025
2 checks passed
@juliasilge juliasilge deleted the force-save-before-switch branch October 1, 2025 17:07
@vezwork
Copy link
Collaborator

vezwork commented Oct 1, 2025

Oh, I seem to have lost my insert ; on save config. Ty for fixing the lint.

edit: made a PR to make that config part of the repo #837

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants