@@ -2,6 +2,9 @@ import * as vscode from "vscode";
22import * as assert from "assert" ;
33import * as path from "path" ;
44import { 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
69suite ( "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