Skip to content

editor: visual in frontmatter causes issues with source/visual mode switch in Positron #805

@sharon-wang

Description

@sharon-wang

Bug description

In Positron, if you have not previously used the Quarto Visual Editor (e.g. in a fresh environment where Positron doesn't have user state yet), specifying editor: visual in the frontmatter of a Quarto document can result in a couple awkward UI experiences:

  1. The first time you "Preview" the document, you get this modal, which is un-cancellable (clicking Cancel seems to cause the editor to reopen and trigger the modal again)

  2. When editor: visual is specified and you try to toggle back to Source mode using the toggle in the Editor Actions, you get kicked back to Visual mode after a similar editor reopen (~1:15 in the video)

quarto_positron_visual_toggle.mp4

Steps to reproduce

PRE-REQ: a fresh Positron installation with no existing Quarto extension state

  1. Create a quarto document that has editor: visual in the YAML frontmatter of the document
  2. Save the file
  3. Click the "Preview" button in the Editor Actions bar
  4. See the modal as described above

Quarto code for the modal:

if (this.context.globalState.get(kVisualModeConfirmed) !== true) {
const kUseVisualMode = "Use Visual Mode";
const kLearnMore = "Learn More...";
const result = await window.showInformationMessage<string>(
"You are activating Quarto visual markdown editing mode.",
{
modal: true,
detail:
"Visual mode enables you to author using a familiar word processor style interface.\n\n" +
"Markdown code will be re-formatted using the Pandoc markdown writer."
},
kUseVisualMode,
kLearnMore
);
if (!result) {
await reopenSourceMode();
return;
} else if (result === kLearnMore) {
await env.openExternal(Uri.parse("https://quarto.org/docs/visual-editor/vscode/#markdown-output"));
await reopenSourceMode();
return;
} else {
this.context.globalState.update(kVisualModeConfirmed, true);
}
}

Actual behavior

No response

Expected behavior

Some ideas for expected behaviour:

  1. The first time you "Preview" the document, you get this modal, which is un-cancellable (clicking Cancel seems to cause the editor to reopen and trigger the modal again)
  • When Cancel is clicked, the user should be allowed back to Source mode, even though editor: visual is in the frontmatter?
  • or, note to the user that they could can editor: visual from the frontmatter to avoid this
  1. When editor: visual is specified and you try to toggle back to Source mode using the toggle in the Editor Actions, you get kicked back to Visual mode
  • editor: <MODE> should set the default mode when the editor for the file is first opened, but if the user manually toggles to a different mode, they should be able to?
  • or, note to the user that editor: visual must be removed if they want to switch to source?

Your environment

See posit-dev/positron#9268 for additional context and environments.

This is 100% reproducible in a fresh demo environment in Workbench. For Desktop builds, I think a state reset is needed before reproducing, as the problem is no longer reproducible once the user has clicked Use Visual Mode in the modal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingvscode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions