Skip to content

Commit c0cf72f

Browse files
committed
Show progress during query operation
1 parent e369ba8 commit c0cf72f

1 file changed

Lines changed: 27 additions & 19 deletions

File tree

src/panel.ts

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,33 @@ export class RegistryPanel implements vscode.WebviewViewProvider {
8181
}
8282

8383
public async query(text: string, register: string, editor?:vscode.TextEditor) {
84-
if (editor) {
85-
this._currentEditor = editor;
86-
}
87-
let results:RegistryResult[] = [];
88-
89-
if (register && register !== '') {
90-
const plugin = this._registry.get(register);
91-
if (plugin) {
92-
const result = await plugin.query(text);
93-
results = result;
94-
}
95-
} else {
96-
for (let plugin of this._registry.values()) {
97-
const result = await plugin.query(text);
98-
results = results.concat(result);
99-
}
100-
}
101-
console.log('Results: %o', results);
102-
this._view?.webview.postMessage({ command: 'results', data: results, query: text });
84+
if (editor) {
85+
this._currentEditor = editor;
86+
}
87+
vscode.window.withProgress({
88+
location: vscode.ProgressLocation.Notification,
89+
title: `Querying authorities for ${text}`,
90+
cancellable: false
91+
}, (progress) => {
92+
return new Promise(async (resolve) => {
93+
let results:RegistryResult[] = [];
94+
95+
if (register && register !== '') {
96+
const plugin = this._registry.get(register);
97+
if (plugin) {
98+
const result = await plugin.query(text);
99+
results = result;
100+
}
101+
} else {
102+
for (let plugin of this._registry.values()) {
103+
const result = await plugin.query(text);
104+
results = results.concat(result);
105+
}
106+
}
107+
this._view?.webview.postMessage({ command: 'results', data: results, query: text });
108+
resolve(true);
109+
});
110+
});
103111
}
104112

105113
private _getHtmlForWebview(webview: vscode.Webview) {

0 commit comments

Comments
 (0)