Skip to content

Commit c451161

Browse files
committed
saving + message after completion
1 parent e2df6d2 commit c451161

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/addImportStatement/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ export default function addImportStatement(
2929
// Insert the import statement at the top of the document
3030
const edit = new vscode.WorkspaceEdit();
3131
edit.insert(document.uri, new vscode.Position(0, 0), importStatement);
32-
vscode.workspace.applyEdit(edit);
32+
vscode.workspace.applyEdit(edit).then(() => {
33+
saveDocument(document);
34+
});
3335
}
3436

3537
function calculateRelativePath(
@@ -66,3 +68,16 @@ function calculateRelativePath(
6668

6769
return relativePath;
6870
}
71+
72+
function saveDocument(document: vscode.TextDocument) {
73+
if (document.isDirty) {
74+
document.save().then(
75+
() => {
76+
vscode.window.showInformationMessage('Stack created successfully 🎉');
77+
},
78+
(err) => {
79+
vscode.window.showErrorMessage(`Error saving document: ${err}`);
80+
}
81+
);
82+
}
83+
}

0 commit comments

Comments
 (0)