Skip to content

fix: Cannot show description page #345

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 1 commit into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
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