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

Several behavior fix#235

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 4 commits intoLeetCode-OpenSource:masterfromVigilans:cs/behaviorfix
Mar 26, 2019
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
4 changes: 2 additions & 2 deletionssrc/commands/show.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,10 +65,10 @@ async function fetchProblemLanguage(): Promise<string | undefined> {
if (defaultLanguage && languages.indexOf(defaultLanguage) < 0) {
defaultLanguage = undefined;
}
const language: string | undefined = defaultLanguage || await vscode.window.showQuickPick(languages, { placeHolder: "Select the language you want to use" });
const language: string | undefined = defaultLanguage || await vscode.window.showQuickPick(languages, { placeHolder: "Select the language you want to use", ignoreFocusOut: true });
// fire-and-forget default language query
(async (): Promise<void> => {
if (!defaultLanguage && leetCodeConfig.get<boolean>("showSetDefaultLanguageHint")) {
if (language &&!defaultLanguage && leetCodeConfig.get<boolean>("showSetDefaultLanguageHint")) {
const choice: vscode.MessageItem | undefined = await vscode.window.showInformationMessage(
`Would you like to set '${language}' as your default language?`,
DialogOptions.yes,
Expand Down
9 changes: 8 additions & 1 deletionsrc/leetCodeExecutor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -111,7 +111,14 @@ class LeetCodeExecutor {
}

public async submitSolution(filePath: string): Promise<string> {
return await this.executeCommandWithProgressEx("Submitting to LeetCode...", "node", [await this.getLeetCodeBinaryPath(), "submit", `"${filePath}"`]);
try {
return await this.executeCommandWithProgressEx("Submitting to LeetCode...", "node", [await this.getLeetCodeBinaryPath(), "submit", `"${filePath}"`]);
} catch (error) {
if (error.result) {
return error.result;
}
throw error;
}
}

public async testSolution(filePath: string, testString?: string): Promise<string> {
Expand Down
11 changes: 10 additions & 1 deletionsrc/utils/cpUtils.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,10 @@ import * as cp from "child_process";
import * as vscode from "vscode";
import { leetCodeChannel } from "../leetCodeChannel";

interface IExecError extends Error {
result?: string;
}

export async function executeCommand(command: string, args: string[], options: cp.SpawnOptions = { shell: true }): Promise<string> {
return new Promise((resolve: (res: string) => void, reject: (e: Error) => void): void => {
let result: string = "";
Expand All@@ -20,9 +24,14 @@ export async function executeCommand(command: string, args: string[], options: c
childProc.stderr.on("data", (data: string | Buffer) => leetCodeChannel.append(data.toString()));

childProc.on("error", reject);

childProc.on("close", (code: number) => {
if (code !== 0 || result.indexOf("ERROR") > -1) {
reject(new Error(`Command "${command} ${args.toString()}" failed with exit code "${code}".`));
const error: IExecError = new Error(`Command "${command} ${args.toString()}" failed with exit code "${code}".`);
if (result) {
error.result = result; // leetcode-cli may print useful content by exit with error code
}
reject(error);
} else {
resolve(result);
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp