Skip to content

Commit

Permalink
fix: Cannot show description page (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdneo authored Jun 14, 2019
1 parent 123d95b commit 1572c7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
11 changes: 4 additions & 7 deletions src/commands/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ import { leetCodeSolutionProvider } from "../webview/leetCodeSolutionProvider";
import * as list from "./list";

export async function previewProblem(input: IProblem | vscode.Uri, isSideMode: boolean = false): Promise<void> {
let node: LeetCodeNode;
if (input instanceof LeetCodeNode) {
node = input;
} else if (input instanceof vscode.Uri) {
let node: IProblem;
if (input instanceof vscode.Uri) {
const activeFilePath: string = input.fsPath;
const id: string = await getNodeIdFromFile(activeFilePath);
if (!id) {
vscode.window.showErrorMessage(`Failed to resolve the problem id from file: ${activeFilePath}.`);
return;
}
const cachedNode: LeetCodeNode | undefined = explorerNodeManager.getNodeById(id);
const cachedNode: IProblem | undefined = explorerNodeManager.getNodeById(id);
if (!cachedNode) {
vscode.window.showErrorMessage(`Failed to resolve the problem with id: ${id}.`);
return;
Expand All @@ -39,8 +37,7 @@ export async function previewProblem(input: IProblem | vscode.Uri, isSideMode: b
// Move the preview page aside if it's triggered from Code Lens
isSideMode = true;
} else {
vscode.window.showErrorMessage("Invalid input to fetch the preview data.");
return;
node = input;
}

const descString: string = await leetCodeExecutor.getDescription(node.id);
Expand Down
16 changes: 9 additions & 7 deletions src/webview/leetCodePreviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
this.node = node;
this.sideMode = isSideMode;
this.showWebviewInternal();
if (this.sideMode) {
this.hideSideBar(); // For better view area
}
// Comment out this operation since it sometimes may cause the webview become empty.
// Waiting for the progress of the VS Code side issue: https://github.com/microsoft/vscode/issues/3742
// if (this.sideMode) {
// this.hideSideBar(); // For better view area
// }
}

protected getWebviewOption(): ILeetCodeWebviewOption {
Expand Down Expand Up @@ -134,10 +136,10 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
}
}

private async hideSideBar(): Promise<void> {
await commands.executeCommand("workbench.action.focusSideBar");
await commands.executeCommand("workbench.action.toggleSidebarVisibility");
}
// private async hideSideBar(): Promise<void> {
// await commands.executeCommand("workbench.action.focusSideBar");
// await commands.executeCommand("workbench.action.toggleSidebarVisibility");
// }

private parseDescription(descString: string, problem: IProblem): IDescription {
const [
Expand Down

0 comments on commit 1572c7a

Please sign in to comment.