Skip to content

Commit 4307811

Browse files
committed
test: add debugging code
1 parent d2f81c8 commit 4307811

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

apps/vscode/src/test/formatting.test.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import * as vscode from "vscode";
22
import * as assert from "assert";
33
import * as path from "path";
44
import { openAndShowTextDocument, wait, WORKSPACE_PATH } from "./test-utils";
5+
import { MarkdownEngine } from "../markdown/engine"; // DEBUGGING
6+
import { embeddedDocumentFormattingProvider } from "../providers/format"; // DEBUGGING
7+
import { isQuartoDoc } from "../core/doc"; // DEBUGGING
58

69
suite("Code Block Formatting", function () {
710
test("Format Python code block", async function () {
@@ -16,8 +19,29 @@ suite("Code Block Formatting", function () {
1619
const position = new vscode.Position(7, 0); // Line with "1+1"
1720
editor.selection = new vscode.Selection(position, position);
1821
await wait(1000);
19-
await vscode.commands.executeCommand("quarto.formatCell");
20-
// await vscode.commands.executeCommand("vscode.executeFormatDocumentProvider", doc.uri);
22+
23+
// DEBUGGING
24+
// Use embeddedDocumentFormattingProvider directly
25+
assert.strictEqual(isQuartoDoc(editor?.document), true);
26+
const engine = new MarkdownEngine();
27+
const provider = embeddedDocumentFormattingProvider(engine);
28+
const next = async () => null;
29+
const edits = await provider(
30+
doc,
31+
{ tabSize: 4, insertSpaces: true },
32+
new vscode.CancellationTokenSource().token,
33+
next
34+
);
35+
assert.notStrictEqual(edits, null, "Provider should return edits");
36+
assert.notStrictEqual(edits, undefined, "Provider should return edits");
37+
assert.ok(Array.isArray(edits), "Edits should be an array");
38+
assert.ok(edits.length > 0, "Provider should return at least one edit");
39+
const editApplied = await editor.edit((editBuilder) => {
40+
edits.forEach((edit) => {
41+
editBuilder.replace(edit.range, edit.newText);
42+
});
43+
});
44+
assert.strictEqual(editApplied, true, "Edits should be successfully applied");
2145

2246
await wait(500);
2347

0 commit comments

Comments
 (0)