Skip to content

Commit b96e7f5

Browse files
authored
fix: Can trigger showTopVotedSolution from keyboard shortcut (LeetCode-OpenSource#399)
1 parent 085b91f commit b96e7f5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/commands/show.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { leetCodeManager } from "../leetCodeManager";
1313
import { IProblem, IQuickItemEx, languages, ProblemState } from "../shared";
1414
import { getNodeIdFromFile } from "../utils/problemUtils";
1515
import { DialogOptions, DialogType, openSettingsEditor, promptForOpenOutputChannel, promptForSignIn, promptHintMessage } from "../utils/uiUtils";
16-
import { selectWorkspaceFolder } from "../utils/workspaceUtils";
16+
import { getActiveFilePath, selectWorkspaceFolder } from "../utils/workspaceUtils";
1717
import * as wsl from "../utils/wslUtils";
1818
import { leetCodePreviewProvider } from "../webview/leetCodePreviewProvider";
1919
import { leetCodeSolutionProvider } from "../webview/leetCodeSolutionProvider";
@@ -71,11 +71,15 @@ export async function searchProblem(): Promise<void> {
7171

7272
export async function showSolution(input: LeetCodeNode | vscode.Uri): Promise<void> {
7373
let problemInput: string | undefined;
74-
if (input instanceof LeetCodeNode) {
74+
if (input instanceof LeetCodeNode) { // Triggerred from explorer
7575
problemInput = input.id;
76-
} else if (input instanceof vscode.Uri) {
76+
} else if (input instanceof vscode.Uri) { // Triggerred from Code Lens/context menu
7777
problemInput = `"${input.fsPath}"`;
78-
} else {
78+
} else if (!input) { // Triggerred from command
79+
problemInput = await getActiveFilePath();
80+
}
81+
82+
if (!problemInput) {
7983
vscode.window.showErrorMessage("Invalid input to fetch the solution data.");
8084
return;
8185
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy