Skip to content

Wrong "Editor selection is not within a code cell that supports formatting." #854

@mcanouil

Description

@mcanouil

Bug description

This is mostly to track real impact of this.

In some cases (unclear what are the requirements here), even though the document is correct and there is a valid code cell, the extension displays an error notification: "Editor selection is not within a code cell that supports formatting."

  • class FormatCellCommand implements Command {
    public readonly id = "quarto.formatCell";
    constructor(private readonly engine_: MarkdownEngine) { }
    public async execute(): Promise<void> {
    const editor = window.activeTextEditor;
    const doc = editor?.document;
    if (doc && isQuartoDoc(doc)) {
    const edits = await formatActiveCell(editor, this.engine_);
    if (edits) {
    editor.edit((editBuilder) => {
    edits.forEach((edit) => {
    editBuilder.replace(edit.range, edit.newText);
    });
    });
    } else {
    window.showInformationMessage(
    "Editor selection is not within a code cell that supports formatting."
    );
    }
    } else {
    window.showInformationMessage("Active editor is not a Quarto document");
    }
    }
    }
Screen.Recording.2025-10-19.at.18.11.01.mov

Steps to reproduce

No response

Actual behavior

No response

Expected behavior

No response

Your environment

  • VSCode 1.105.1
  • Quarto extension 1.126.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions