-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Closed
Copy link
Labels
vscodeissues related to VSCode compatibilityissues related to VSCode compatibility
Description
Discussed in #15692
Originally posted by safisa June 1, 2025
Hi,
I have a vscode extension that uses the vscode.workspace.onWillSaveTextDocument API. I see that in the latest Theia 1.62 this API is not triggered anymore.
NOTE that it is NOT working on custom editors only.
Is it a regression issue in Theia?
I have built a small one that demonstrates it, and you can check it on a text editor where it should work, and on a custom editor where it does not work. When you try it on older Theia versions (I tried 1.57), it worked on both types.
Here is the extension code:
export function activate(context: vscode.ExtensionContext) {
let channel = vscode.window.createOutputChannel("willSave Test");
// Register the onWillSaveTextDocument event
vscode.workspace.onWillSaveTextDocument(event => {
// Log a message when a document is about to be saved
channel.appendLine(`Document ${event.document.uri} is about to be saved`);
let p = new Promise((resolve, reject) => {
channel.appendLine(`Pre save`);
let data = event.document.getText();
// data manipulation...
resolve(data);
}).then(res => {
let textRange = new vscode.Range(0, 0, event.document.lineCount, 0);
let textEdit = vscode.TextEdit.replace(textRange, `${res}`);
return [textEdit];
});
event.waitUntil(p);
p.then(res => {
if (res) {
channel.appendLine(`Post save`);
//this.postSave(doc.uri, res[0].newText);
}
});
});
}
And here is the vsix file:
Metadata
Metadata
Assignees
Labels
vscodeissues related to VSCode compatibilityissues related to VSCode compatibility