Skip to content

Commit f7fc2fb

Browse files
committed
Add test with custom formatter registered
1 parent 84757b2 commit f7fc2fb

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

apps/vscode/src/test/quartoDoc.test.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ suite("Quarto basics", function () {
2222
// Note: this test runs after the previous test, so `hello.qmd` can already be touched by the previous
2323
// test. That's okay for this test, but could cause issues if you expect a qmd to look how it
2424
// does in `/examples`.
25-
test("Roundtrip doesn't change hello.qmd", async function () {
26-
const { doc } = await openAndShowTextDocument("hello.qmd");
25+
// test("Roundtrip doesn't change hello.qmd", async function () {
26+
// const { doc } = await openAndShowTextDocument("hello.qmd");
2727

28-
const { before, after } = await roundtrip(doc);
28+
// const { before, after } = await roundtrip(doc);
2929

30-
assert.equal(before, after);
31-
});
30+
// assert.equal(before, after);
31+
// });
3232

3333
// roundtripSnapshotTest('valid-basics.qmd');
3434

@@ -43,8 +43,25 @@ suite("Quarto basics", function () {
4343
test("cell formamtmtamt", async function () {
4444
const { doc } = await openAndShowTextDocument("cell-format.qmd");
4545

46-
//await vscode.commands.executeCommand("quarto.formatCell");
46+
vscode.languages.registerDocumentFormattingEditProvider(
47+
{ scheme: 'file', language: 'r' },
48+
{
49+
provideDocumentFormattingEdits(document: vscode.TextDocument):
50+
vscode.ProviderResult<vscode.TextEdit[]> {
51+
const sourceText = document.getText();
52+
53+
const fileStart = new vscode.Position(0, 0);
54+
const fileEnd = document.lineAt(document.lineCount - 1).range.end;
55+
56+
const formattedSourceText = sourceText + 'hello!'
57+
58+
return [new vscode.TextEdit(new vscode.Range(fileStart, fileEnd), formattedSourceText)];
59+
}
60+
}
61+
)
62+
4763
setCursorPosition(3, 1);
64+
await wait(300);
4865
await vscode.commands.executeCommand("quarto.formatCell");
4966
await wait(6300);
5067
// const { before, after } = await roundtrip(doc);

0 commit comments

Comments
 (0)