I'm creating this vscode exntension, sqlsurge. And I'm trying to implement SQL formatting feature in this extension.
I tried executeFormatDocumentProvider
command API like this.
vscode.commands.executeCommand<vscode.TextEdit[]>(
"vscode.executeFormatDocumentProvider",
vscode.Uri.parse("sqlsurge:///home/senken/personal/sqlsurge/vsce/test-workspace-rs-sqlx/src/[email protected]"),
);
But it does not worked on virtual document and got an error. Why?
Error: Unable to resolve text model content for resource sqlsurge:/home/senken/personal/sqlsurge/vsce/test-workspace-rs-sqlx/src/main.rs%401.sql
at u (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:2359:26819)
at async u.r (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:2359:25810)
at async k.acquire (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:37:3320)
at async d.createModelReference (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:2359:27297)
at async vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:694:53986 {name: 'Error', message: 'Unable to resolve text model content for res…e/test-workspace-rs-sqlx/src/main.rs%401.sql', stack: 'Error: Unable to resolve text model content f…workbench/workbench.desktop.main.js:694:53986'}
Normal SQL file like below worked.
vscode.commands.executeCommand<vscode.TextEdit[]>(
"vscode.executeFormatDocumentProvider",
vscode.Uri.parse("file:///home/senken/personal/sqlsurge/vsce/test-workspace-rs-sqlx/src/foo.sql"),
); // worked
I expect that I would receive vscode.TextEdit[]
from executeFormatDocumentProvider
commands return like this in the case of virtual document.