Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbd9da79

Browse files
committed
add progress bar when submit
1 parent812544a commitbd9da79

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

‎src/commands/submit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import*asvscodefrom"vscode";
44
import{leetCodeManager}from"../leetCodeManager";
55
import{leetCodeBinaryPath}from"../shared";
6-
import{executeCommand}from"../utils/cpUtils";
6+
import{executeCommandWithProgress}from"../utils/cpUtils";
77
import{DialogType,promptForOpenOutputChannel,promptForSignIn,showResultFile}from"../utils/uiUtils";
88
import{getActivefilePath}from"../utils/workspaceUtils";
99

@@ -19,7 +19,7 @@ export async function submitSolution(channel: vscode.OutputChannel, uri?: vscode
1919
}
2020

2121
try{
22-
constresult:string=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"submit",`"${filePath}"`]);
22+
constresult:string=awaitexecuteCommandWithProgress("Submitting to LeetCode...",channel,"node",[leetCodeBinaryPath,"submit",`"${filePath}"`]);
2323
awaitshowResultFile(result);
2424
}catch(error){
2525
awaitpromptForOpenOutputChannel("Failed to submit the solution. Please open the output channel for details.",DialogType.error,channel);

‎src/commands/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as fse from "fs-extra";
44
import*asvscodefrom"vscode";
55
import{leetCodeManager}from"../leetCodeManager";
66
import{IQuickItemEx,leetCodeBinaryPath,UserStatus}from"../shared";
7-
import{executeCommand}from"../utils/cpUtils";
7+
import{executeCommandWithProgress}from"../utils/cpUtils";
88
import{DialogType,promptForOpenOutputChannel,showFileSelectDialog,showResultFile}from"../utils/uiUtils";
99
import{getActivefilePath}from"../utils/workspaceUtils";
1010

@@ -47,7 +47,7 @@ export async function testSolution(channel: vscode.OutputChannel, uri?: vscode.U
4747
letresult:string|undefined;
4848
switch(choice.value){
4949
case":default":
50-
result=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"test",`"${filePath}"`]);
50+
result=awaitexecuteCommandWithProgress("Submitting to LeetCode...",channel,"node",[leetCodeBinaryPath,"test",`"${filePath}"`]);
5151
break;
5252
case":direct":
5353
consttestString:string|undefined=awaitvscode.window.showInputBox({
@@ -57,15 +57,15 @@ export async function testSolution(channel: vscode.OutputChannel, uri?: vscode.U
5757
ignoreFocusOut:true,
5858
});
5959
if(testString){
60-
result=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"test",`"${filePath}"`,"-t",`"${testString.replace(/"/g,"")}"`]);
60+
result=awaitexecuteCommandWithProgress("Submitting to LeetCode...",channel,"node",[leetCodeBinaryPath,"test",`"${filePath}"`,"-t",`"${testString.replace(/"/g,"")}"`]);
6161
}
6262
break;
6363
case":file":
6464
consttestFile:vscode.Uri[]|undefined=awaitshowFileSelectDialog();
6565
if(testFile&&testFile.length){
6666
constinput:string=awaitfse.readFile(testFile[0].fsPath,"utf-8");
6767
if(input.trim()){
68-
result=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"test",`"${filePath}"`,"-t",`"${input.replace(/"/g,"").replace(/\r?\n/g,"\\n")}"`]);
68+
result=awaitexecuteCommandWithProgress("Submitting to LeetCode...",channel,"node",[leetCodeBinaryPath,"test",`"${filePath}"`,"-t",`"${input.replace(/"/g,"").replace(/\r?\n/g,"\\n")}"`]);
6969
}else{
7070
vscode.window.showErrorMessage("The selected test file must not be empty.");
7171
}

‎src/utils/cpUtils.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,19 @@ export async function executeCommand(channel: vscode.OutputChannel, command: str
2626
});
2727
});
2828
}
29+
30+
exportasyncfunctionexecuteCommandWithProgress(message:string,channel:vscode.OutputChannel,command:string,args:string[],options:cp.SpawnOptions={shell:true}):Promise<string>{
31+
letresult:string="";
32+
awaitvscode.window.withProgress({location:vscode.ProgressLocation.Window},async(p:vscode.Progress<{}>)=>{
33+
returnnewPromise(async(resolve:()=>void,reject:(e:Error)=>void):Promise<void>=>{
34+
p.report({ message});
35+
try{
36+
result=awaitexecuteCommand(channel,command,args,options);
37+
resolve();
38+
}catch(e){
39+
reject(e);
40+
}
41+
});
42+
});
43+
returnresult;
44+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp