Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit 6cb7eb7

Browse files
committed
Added cancel prompt
1 parent e688cf0 commit 6cb7eb7

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/commands/scansel.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ export default async function (){
1313
let text = editor.document.getText(selection);
1414
if(text === ""){
1515
vscode.window.showWarningMessage("Empty selection");
16-
return;
1716
}
1817
console.log("Prompt: ", text);
1918
let result: string | null;
2019
let requests: number = vscode.workspace.getConfiguration("starcoderex").get("countofrequests")!;
2120
vscode.window.withProgress({
2221
location: vscode.ProgressLocation.Notification,
23-
cancellable: false,
24-
title: 'Prompt executing...'
25-
}, async (progress) => {
22+
cancellable: true,
23+
title: 'Prompt executing',
24+
}, async (progress, token) => {
2625
for(let i = 0; i < requests; i++){
27-
progress.report({ increment: ((1/requests)*100) - 1 });
26+
if(token.isCancellationRequested){
27+
return;
28+
}
29+
progress.report({ increment: ((1/requests)*100) - 1, message: `${i+1}/${requests}` });
2830
result = await request(text);
2931
if(!result){
3032
return;
@@ -35,15 +37,6 @@ export default async function (){
3537
edBuiler.delete(selection);
3638
}).then(() => {
3739
progress.report({ increment: 100 });
38-
//Docs window <START
39-
// vscode.comments.createCommentController("123","123")
40-
// .createCommentThread(
41-
// vscode.window.activeTextEditor?.document.uri!,
42-
// new vscode.Range(editor.selection.active, editor.selection.end),
43-
// List));
44-
//vscode.window.createQuickPick();
45-
//vscode.window.createWebviewPanel("text","hello world", ViewColumn.Active, undefined);
46-
//Docs window <END
4740
editor.insertSnippet(new vscode.SnippetString(result!), editor.selection.start);
4841
vscode.window.showInformationMessage("Done!");
4942
});

0 commit comments

Comments
 (0)