@@ -13,18 +13,20 @@ export default async function (){
13
13
let text = editor . document . getText ( selection ) ;
14
14
if ( text === "" ) {
15
15
vscode . window . showWarningMessage ( "Empty selection" ) ;
16
- return ;
17
16
}
18
17
console . log ( "Prompt: " , text ) ;
19
18
let result : string | null ;
20
19
let requests : number = vscode . workspace . getConfiguration ( "starcoderex" ) . get ( "countofrequests" ) ! ;
21
20
vscode . window . withProgress ( {
22
21
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 ) => {
26
25
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 } ` } ) ;
28
30
result = await request ( text ) ;
29
31
if ( ! result ) {
30
32
return ;
@@ -35,15 +37,6 @@ export default async function (){
35
37
edBuiler . delete ( selection ) ;
36
38
} ) . then ( ( ) => {
37
39
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
47
40
editor . insertSnippet ( new vscode . SnippetString ( result ! ) , editor . selection . start ) ;
48
41
vscode . window . showInformationMessage ( "Done!" ) ;
49
42
} ) ;
0 commit comments