Skip to content

Commit a8957d4

Browse files
committed
Prompt the user about cyclic dependency and give them a choice
1 parent 9691102 commit a8957d4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/extension.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ async function getFileContent(
4949
return cycle;
5050
})(file);
5151
if (has_cycle) {
52-
vscode.window.showWarningMessage('Cyclic dependency found from template');
52+
const choice = await vscode.window.showWarningMessage(
53+
'Cyclic dependency found! Do you still want to insert the template?',
54+
'Yes',
55+
'No',
56+
);
57+
if (choice === 'No') {
58+
return undefined;
59+
}
5360
}
5461

5562
const contents = await Promise.all(
@@ -225,6 +232,10 @@ function registerCommands(context: vscode.ExtensionContext): void {
225232
baseDirectory,
226233
dependencies ?? {},
227234
);
235+
if (!content) {
236+
return;
237+
}
238+
228239
const inserted = vscode.window.activeTextEditor?.edit(
229240
(edit: vscode.TextEditorEdit) => {
230241
if (vscode.window.activeTextEditor) {

0 commit comments

Comments
 (0)