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

Commit81e9d53

Browse files
authored
support submit from the file explorer (LeetCode-OpenSource#29)
1 parent0bf5b96 commit81e9d53

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

‎package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
},
8787
{
8888
"command":"leetcode.submitSolution",
89-
"title":"Submit",
89+
"title":"Submit to LeetCode",
9090
"category":"LeetCode"
9191
}
9292
],
@@ -123,6 +123,12 @@
123123
"command":"leetcode.showProblem",
124124
"when":"never"
125125
}
126+
],
127+
"explorer/context": [
128+
{
129+
"command":"leetcode.submitSolution",
130+
"when":"explorerResourceIsFolder == false"
131+
}
126132
]
127133
},
128134
"configuration": [

‎src/commands/submit.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,27 @@ import { leetCodeBinaryPath } from "../shared";
66
import{executeCommand}from"../utils/cpUtils";
77
import{DialogType,promptForOpenOutputChannel,promptForSignIn,showResultFile}from"../utils/uiUtils";
88

9-
exportasyncfunctionsubmitSolution(channel:vscode.OutputChannel):Promise<void>{
9+
exportasyncfunctionsubmitSolution(channel:vscode.OutputChannel,uri?:vscode.Uri):Promise<void>{
1010
if(!leetCodeManager.getUser()){
1111
promptForSignIn();
1212
return;
1313
}
14-
consttextEditor:vscode.TextEditor|undefined=vscode.window.activeTextEditor;
15-
if(!textEditor){
16-
return;
17-
}
18-
if(!textEditor.document.save()){
19-
vscode.window.showWarningMessage("Please save the solution file first.");
20-
return;
14+
15+
letfilePath:string;
16+
if(uri){
17+
filePath=uri.fsPath;
18+
}else{
19+
consttextEditor:vscode.TextEditor|undefined=vscode.window.activeTextEditor;
20+
if(!textEditor){
21+
return;
22+
}
23+
if(!textEditor.document.save()){
24+
vscode.window.showWarningMessage("Please save the solution file first.");
25+
return;
26+
}
27+
filePath=textEditor.document.uri.fsPath;
2128
}
22-
constfilePath:string=textEditor.document.uri.fsPath;
29+
2330
try{
2431
constresult:string=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"submit",filePath]);
2532
awaitshowResultFile(result);

‎src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function activate(context: vscode.ExtensionContext) {
2828
vscode.commands.registerCommand("leetcode.searchProblem",()=>show.searchProblem(channel)),
2929
vscode.commands.registerCommand("leetcode.refreshExplorer",()=>leetCodeTreeDataProvider.refresh()),
3030
vscode.commands.registerCommand("leetcode.testSolution",()=>test.testSolution(channel)),
31-
vscode.commands.registerCommand("leetcode.submitSolution",()=>submit.submitSolution(channel)),
31+
vscode.commands.registerCommand("leetcode.submitSolution",(uri:vscode.Uri)=>submit.submitSolution(channel,uri)),
3232
);
3333

3434
leetCodeManager.on("statusChanged",()=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp