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

support submit from the file explorer#29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jdneo merged 1 commit intomasterfromcs/submit
Mar 19, 2018
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletionpackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,7 +86,7 @@
},
{
"command": "leetcode.submitSolution",
"title": "Submit",
"title": "Submit to LeetCode",
"category": "LeetCode"
}
],
Expand DownExpand Up@@ -123,6 +123,12 @@
"command": "leetcode.showProblem",
"when": "never"
}
],
"explorer/context": [
{
"command": "leetcode.submitSolution",
"when": "explorerResourceIsFolder == false"
}
]
},
"configuration": [
Expand Down
25 changes: 16 additions & 9 deletionssrc/commands/submit.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,20 +6,27 @@ import { leetCodeBinaryPath } from "../shared";
import { executeCommand } from "../utils/cpUtils";
import { DialogType, promptForOpenOutputChannel, promptForSignIn, showResultFile } from "../utils/uiUtils";

export async function submitSolution(channel: vscode.OutputChannel): Promise<void> {
export async function submitSolution(channel: vscode.OutputChannel, uri?: vscode.Uri): Promise<void> {
if (!leetCodeManager.getUser()) {
promptForSignIn();
return;
}
const textEditor: vscode.TextEditor | undefined = vscode.window.activeTextEditor;
if (!textEditor) {
return;
}
if (!textEditor.document.save()) {
vscode.window.showWarningMessage("Please save the solution file first.");
return;

let filePath: string;
if (uri) {
filePath = uri.fsPath;
} else {
const textEditor: vscode.TextEditor | undefined = vscode.window.activeTextEditor;
if (!textEditor) {
return;
}
if (!textEditor.document.save()) {
vscode.window.showWarningMessage("Please save the solution file first.");
return;
}
filePath = textEditor.document.uri.fsPath;
}
const filePath: string = textEditor.document.uri.fsPath;

try {
const result: string = await executeCommand(channel, "node", [leetCodeBinaryPath, "submit", filePath]);
await showResultFile(result);
Expand Down
2 changes: 1 addition & 1 deletionsrc/extension.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand("leetcode.searchProblem", () => show.searchProblem(channel)),
vscode.commands.registerCommand("leetcode.refreshExplorer", () => leetCodeTreeDataProvider.refresh()),
vscode.commands.registerCommand("leetcode.testSolution", () => test.testSolution(channel)),
vscode.commands.registerCommand("leetcode.submitSolution", () => submit.submitSolution(channel)),
vscode.commands.registerCommand("leetcode.submitSolution", (uri: vscode.Uri) => submit.submitSolution(channel, uri)),
);

leetCodeManager.on("statusChanged", () => {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp