Skip to content

fix: Can trigger showTopVotedSolution from keyboard shortcut #399

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 27, 2019
Merged
Changes from 1 commit
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
Next Next commit
fix: Can trigger showTopVotedSolution from keyboard shortcut
  • Loading branch information
jdneo committed Aug 24, 2019
commit 399d2b73d27bccce72ef96640a616535e77b0124
12 changes: 8 additions & 4 deletions src/commands/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { leetCodeManager } from "../leetCodeManager";
import { IProblem, IQuickItemEx, languages, ProblemState } from "../shared";
import { getNodeIdFromFile } from "../utils/problemUtils";
import { DialogOptions, DialogType, openSettingsEditor, promptForOpenOutputChannel, promptForSignIn, promptHintMessage } from "../utils/uiUtils";
import { selectWorkspaceFolder } from "../utils/workspaceUtils";
import { getActiveFilePath, selectWorkspaceFolder } from "../utils/workspaceUtils";
import * as wsl from "../utils/wslUtils";
import { leetCodePreviewProvider } from "../webview/leetCodePreviewProvider";
import { leetCodeSolutionProvider } from "../webview/leetCodeSolutionProvider";
Expand Down Expand Up @@ -71,11 +71,15 @@ export async function searchProblem(): Promise<void> {

export async function showSolution(input: LeetCodeNode | vscode.Uri): Promise<void> {
let problemInput: string | undefined;
if (input instanceof LeetCodeNode) {
if (input instanceof LeetCodeNode) { // Triggerred from explorer
problemInput = input.id;
} else if (input instanceof vscode.Uri) {
} else if (input instanceof vscode.Uri) { // Triggerred from Code Lens/context menu
problemInput = `"${input.fsPath}"`;
} else {
} else if (!input) { // Triggerred from command
problemInput = await getActiveFilePath();
}

if (!problemInput) {
vscode.window.showErrorMessage("Invalid input to fetch the solution data.");
return;
}
Expand Down