Skip to content

Commit 0f45300

Browse files
committed
changed vscode error to showNotification func, imported from /src/utils, to allow programmatic dissmisal of modal if no file was selected
1 parent 2e9b9be commit 0f45300

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as vscode from 'vscode';
22
import {createPanel} from './panel';
33
import { Parser } from './parser';
44
import { Tree } from './types/tree';
5+
import { showNotification } from './utils/modal';
56

67
let tree: Parser | undefined = undefined;
78
let panel: vscode.WebviewPanel | undefined = undefined;
@@ -27,7 +28,7 @@ function activate(context: vscode.ExtensionContext) {
2728

2829
// Throw error message if no file was selected
2930
if (!fileArray || fileArray.length === 0) {
30-
vscode.window.showErrorMessage('No file selected');
31+
showNotification({message: 'No file selected'});
3132
return;
3233
}
3334

src/utils/modal.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as vscode from 'vscode';
2+
3+
export async function showNotification({message, timeout = 5000 }: { message: string, timeout?: number }) {
4+
await vscode.window.withProgress(
5+
{
6+
location: vscode.ProgressLocation.Notification,
7+
cancellable: false
8+
},
9+
async (progress) => {
10+
progress.report({ increment: 100, message: `${message}` });
11+
await new Promise((resolve) => setTimeout(resolve, timeout));
12+
}
13+
);
14+
}

0 commit comments

Comments
 (0)