From 94b8b9a5cfa8a1ab6e9abcba4f0cadad559c45f9 Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 8 Apr 2019 17:36:49 -0500 Subject: [PATCH] Fix window.open infinite loop --- packages/vscode/src/fill/windowsService.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/vscode/src/fill/windowsService.ts b/packages/vscode/src/fill/windowsService.ts index 512ca757e..2f7b3e9fb 100644 --- a/packages/vscode/src/fill/windowsService.ts +++ b/packages/vscode/src/fill/windowsService.ts @@ -10,6 +10,15 @@ import { client } from "../client"; import { showOpenDialog } from "../dialog"; import { workbench } from "../workbench"; +// VS Code overrides window.open to call openExternal, but we then call +// window.open which results in an infinite loop. Store the function but also +// make it unable to be set (doesn't work otherwise). +const windowOpen = window.open; +Object.defineProperty(window, "open", { + set: (): void => { /* Not allowed. */ }, + get: (): Function => windowOpen, +}); + /** * Instead of going to the shared process, we'll directly run these methods on * the client. This setup means we can only control the current window.