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

Commit3028be4

Browse files
Vigilansjdneo
authored andcommitted
1 parentbcafa92 commit3028be4

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

‎src/commands/show.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ async function fetchProblemLanguage(): Promise<string | undefined> {
6565
if(defaultLanguage&&languages.indexOf(defaultLanguage)<0){
6666
defaultLanguage=undefined;
6767
}
68-
constlanguage:string|undefined=defaultLanguage||awaitvscode.window.showQuickPick(languages,{placeHolder:"Select the language you want to use"});
68+
constlanguage:string|undefined=defaultLanguage||awaitvscode.window.showQuickPick(languages,{placeHolder:"Select the language you want to use",ignoreFocusOut:true});
6969
// fire-and-forget default language query
7070
(async():Promise<void>=>{
71-
if(!defaultLanguage&&leetCodeConfig.get<boolean>("showSetDefaultLanguageHint")){
71+
if(language&&!defaultLanguage&&leetCodeConfig.get<boolean>("showSetDefaultLanguageHint")){
7272
constchoice:vscode.MessageItem|undefined=awaitvscode.window.showInformationMessage(
7373
`Would you like to set '${language}' as your default language?`,
7474
DialogOptions.yes,

‎src/leetCodeExecutor.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,14 @@ class LeetCodeExecutor {
111111
}
112112

113113
publicasyncsubmitSolution(filePath:string):Promise<string>{
114-
returnawaitthis.executeCommandWithProgressEx("Submitting to LeetCode...","node",[awaitthis.getLeetCodeBinaryPath(),"submit",`"${filePath}"`]);
114+
try{
115+
returnawaitthis.executeCommandWithProgressEx("Submitting to LeetCode...","node",[awaitthis.getLeetCodeBinaryPath(),"submit",`"${filePath}"`]);
116+
}catch(error){
117+
if(error.result){
118+
returnerror.result;
119+
}
120+
throwerror;
121+
}
115122
}
116123

117124
publicasynctestSolution(filePath:string,testString?:string):Promise<string>{

‎src/utils/cpUtils.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import * as cp from "child_process";
55
import*asvscodefrom"vscode";
66
import{leetCodeChannel}from"../leetCodeChannel";
77

8+
interfaceIExecErrorextendsError{
9+
result?:string;
10+
}
11+
812
exportasyncfunctionexecuteCommand(command:string,args:string[],options:cp.SpawnOptions={shell:true}):Promise<string>{
913
returnnewPromise((resolve:(res:string)=>void,reject:(e:Error)=>void):void=>{
1014
letresult:string="";
@@ -20,9 +24,14 @@ export async function executeCommand(command: string, args: string[], options: c
2024
childProc.stderr.on("data",(data:string|Buffer)=>leetCodeChannel.append(data.toString()));
2125

2226
childProc.on("error",reject);
27+
2328
childProc.on("close",(code:number)=>{
2429
if(code!==0||result.indexOf("ERROR")>-1){
25-
reject(newError(`Command "${command}${args.toString()}" failed with exit code "${code}".`));
30+
consterror:IExecError=newError(`Command "${command}${args.toString()}" failed with exit code "${code}".`);
31+
if(result){
32+
error.result=result;// leetcode-cli may print useful content by exit with error code
33+
}
34+
reject(error);
2635
}else{
2736
resolve(result);
2837
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp