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

fix the icon bug in explorer#14

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 3 commits intomasterfromcs/fix
Feb 26, 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
Binary file addedresources/x.png
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 20 additions & 4 deletionssrc/commands/list.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,13 +2,12 @@

import * as vscode from "vscode";
import { leetCodeManager } from "../leetCodeManager";
import { leetCodeBinaryPath } from "../shared";
import { UserStatus } from "../shared";
import { leetCodeBinaryPath, ProblemState, UserStatus } from "../shared";
import { executeCommand } from "../utils/cpUtils";
import { DialogType, promptForOpenOutputChannel } from "../utils/uiUtils";

export interface IProblem {
solved: boolean;
state: ProblemState;
id: string;
name: string;
difficulty: string;
Expand All@@ -28,7 +27,7 @@ export async function listProblems(channel: vscode.OutputChannel): Promise<IProb
const match: RegExpMatchArray | null = line.match(reg);
if (match && match.length === 6) {
problems.push({
solved: !!(match[1].trim()),
state: parseProblemState(match[1]),
id: match[2].trim(),
name: match[3].trim(),
difficulty: match[4].trim(),
Expand All@@ -41,5 +40,22 @@ export async function listProblems(channel: vscode.OutputChannel): Promise<IProb
await promptForOpenOutputChannel("Failed to list problems. Please open the output channel for details", DialogType.error, channel);
return [];
}
}

function parseProblemState(stateOutput: string): ProblemState {
if (!stateOutput) {
return ProblemState.Unknown;
}
switch (stateOutput.trim()) {
case "v":
case "✔":
case "√":
return ProblemState.AC;
case "X":
case "✘":
case "×":
return ProblemState.NotAC;
default:
return ProblemState.Unknown;
}
}
15 changes: 13 additions & 2 deletionssrc/commands/show.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ import * as fse from "fs-extra";
import * as vscode from "vscode";
import { LeetCodeNode } from "../leetCodeExplorer";
import { leetCodeManager } from "../leetCodeManager";
import { IQuickItemEx, languages, leetCodeBinaryPath } from "../shared";
import { IQuickItemEx, languages, leetCodeBinaryPath, ProblemState } from "../shared";
import { executeCommand } from "../utils/cpUtils";
import { DialogOptions, DialogType, promptForOpenOutputChannel, promptForSignIn } from "../utils/uiUtils";
import { selectWorkspaceFolder } from "../utils/workspaceUtils";
Expand DownExpand Up@@ -79,11 +79,22 @@ async function showProblemInternal(channel: vscode.OutputChannel, id: string): P
async function parseProblemsToPicks(p: Promise<list.IProblem[]>): Promise<Array<IQuickItemEx<string>>> {
return new Promise(async (resolve: (res: Array<IQuickItemEx<string>>) => void): Promise<void> => {
const picks: Array<IQuickItemEx<string>> = (await p).map((problem: list.IProblem) => Object.assign({}, {
label: `${problem.solved ? "$(check) " : ""}${problem.id}.${problem.name}`,
label: `${parseProblemDecorator(problem.state)}${problem.id}.${problem.name}`,
description: "",
detail: `AC rate: ${problem.passRate}, Difficulty: ${problem.difficulty}`,
value: problem.id,
}));
resolve(picks);
});
}

function parseProblemDecorator(state: ProblemState): string {
switch (state) {
case ProblemState.AC:
return "$(check) ";
case ProblemState.NotAC:
return "$(x) ";
default:
return "";
}
}
31 changes: 22 additions & 9 deletionssrc/leetCodeExplorer.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@ import * as path from "path";
import * as vscode from "vscode";
import * as list from "./commands/list";
import { leetCodeManager } from "./leetCodeManager";
import { ProblemState } from "./shared";

// tslint:disable:max-classes-per-file
export class LeetCodeNode {
Expand All@@ -13,8 +14,8 @@ export class LeetCodeNode {
return this.data.name;
}

public getsolved():boolean {
return this.data.solved;
public getstate():ProblemState {
return this.data.state;
}

public get id(): string {
Expand DownExpand Up@@ -64,11 +65,7 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
id: `${idPrefix}.${element.id}`,
collapsibleState: element.isProblem ? vscode.TreeItemCollapsibleState.None : vscode.TreeItemCollapsibleState.Collapsed,
contextValue: element.isProblem ? "problem" : "difficulty",
iconPath: element.isProblem ?
(element.solved ?
this.context.asAbsolutePath(path.join("resources", "check.png"))
: this.context.asAbsolutePath(path.join("resources", "blank.png")))
: "",
iconPath: this.parseIconPathFromProblemState(element),
};
}

Expand All@@ -77,7 +74,7 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
return [
new LeetCodeNode(
{
solved: false,
state: ProblemState.Unknown,
id: "notSignIn",
name: "Sign in to LeetCode",
difficulty: "",
Expand DownExpand Up@@ -128,7 +125,7 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
difficultynodes.push(
new LeetCodeNode(
{
solved: false,
state: ProblemState.Unknown,
id: difficulty,
name: difficulty,
difficulty: "",
Expand All@@ -155,4 +152,20 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
});
return difficultynodes;
}

private parseIconPathFromProblemState(element: LeetCodeNode): string {
if (!element.isProblem) {
return "";
}
switch (element.state) {
case ProblemState.AC:
return this.context.asAbsolutePath(path.join("resources", "check.png"));
case ProblemState.NotAC:
return this.context.asAbsolutePath(path.join("resources", "x.png"));
case ProblemState.Unknown:
return this.context.asAbsolutePath(path.join("resources", "blank.png"));
default:
return "";
}
}
}
6 changes: 6 additions & 0 deletionssrc/shared.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,3 +30,9 @@ export const languages = [
"scala",
"swift",
];

export enum ProblemState {
AC = 1,
NotAC = 2,
Unknown = 3,
}

[8]ページ先頭

©2009-2025 Movatter.jp