Skip to content

Formatting Q# cell erases %%qsharp magic #1308

@minestarks

Description

@minestarks

Repro steps:

  1. In VS Code, run "Create: new Jupyter notebook" command to create a notebook.
  2. Type this in a code cell:
%%qsharp

operation Foo() : Unit {
    
}
  1. Hit Alt-Shift-F to format the cell.

Expected:

  • Code is formatted and the %%qsharp cell remains at the top

Actual:

  • %%qsharp cell is gone.

I'm fairly sure the code below is the issue. We erase the %%qsharp magic and replace it with whitespace when communicating with the language service, and the formatter of course gets rid of that "whitespace"... Maybe we can replace it with a comment or something instead.

https://github.com/microsoft/qsharp/blob/7c2296061bf46a3ef6203f1fdfa0fc09857033c6/vscode/src/notebook.ts#L200-L203

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions