MCPcopy Create free account
hub / github.com/LeetCode-OpenSource/vscode-leetcode / previewProblem

Function previewProblem

src/commands/show.ts:24–47  ·  view source on GitHub ↗
(input: IProblem | vscode.Uri, isSideMode: boolean = false)

Source from the content-addressed store, hash-verified

22import * as list from "./list";
23
24export async function previewProblem(input: IProblem | vscode.Uri, isSideMode: boolean = false): Promise<void> {
25 let node: IProblem;
26 if (input instanceof vscode.Uri) {
27 const activeFilePath: string = input.fsPath;
28 const id: string = await getNodeIdFromFile(activeFilePath);
29 if (!id) {
30 vscode.window.showErrorMessage(`Failed to resolve the problem id from file: ${activeFilePath}.`);
31 return;
32 }
33 const cachedNode: IProblem | undefined = explorerNodeManager.getNodeById(id);
34 if (!cachedNode) {
35 vscode.window.showErrorMessage(`Failed to resolve the problem with id: ${id}.`);
36 return;
37 }
38 node = cachedNode;
39 // Move the preview page aside if it's triggered from Code Lens
40 isSideMode = true;
41 } else {
42 node = input;
43 }
44 const needTranslation: boolean = settingUtils.shouldUseEndpointTranslation();
45 const descString: string = await leetCodeExecutor.getDescription(node.id, needTranslation);
46 leetCodePreviewProvider.show(descString, node, isSideMode);
47}
48
49export async function pickOne(): Promise<void> {
50 const problems: IProblem[] = await list.listProblems();

Callers 1

showDescriptionViewFunction · 0.85

Calls 4

getNodeIdFromFileFunction · 0.90
getNodeByIdMethod · 0.80
getDescriptionMethod · 0.80
showMethod · 0.45

Tested by

no test coverage detected