From f8067ffadab178d2929a162408032ff63b0b717b Mon Sep 17 00:00:00 2001 From: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com> Date: Thu, 24 Oct 2019 22:14:24 -0700 Subject: [PATCH] Fix for Markdown File in Jupyter Books Viewlet not Opening After 2x (#8009) * fix for markdown not opening after opened twice * PR comment to add return type --- extensions/notebook/src/book/bookTreeView.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/extensions/notebook/src/book/bookTreeView.ts b/extensions/notebook/src/book/bookTreeView.ts index 17df14203d..afe4e48a40 100644 --- a/extensions/notebook/src/book/bookTreeView.ts +++ b/extensions/notebook/src/book/bookTreeView.ts @@ -203,8 +203,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider void) { const isResourceChange = resource !== this._resource; if (isResourceChange) { - clearTimeout(this._throttleTimer); - this._throttleTimer = undefined; + this.clearAndResetThrottleTimer(); } this._resource = resource; @@ -214,11 +213,19 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider action(), 300); + this._throttleTimer = setTimeout(() => { + action(); + this.clearAndResetThrottleTimer(); + }, 300); } } } + private clearAndResetThrottleTimer(): void { + clearTimeout(this._throttleTimer); + this._throttleTimer = undefined; + } + openExternalLink(resource: string): void { try { vscode.env.openExternal(vscode.Uri.parse(resource));