Repository: microsoft/vscode-edge-devtools
Pull request #131 (2020-04-23 23:44:50)

Disabling Quick Open Action (CTRL+P)
The Quick Open menu is available via (CTRL + P), but the functionality is disabled in the extension.  This PR disables the quick open command so the menu will not pop up.
![image](https://user-images.githubusercontent.com/14304598/80160153-bc05e600-8581-11ea-892f-28596109439c.png)



Patch:
diff --git a/postBuildStep.ts b/postBuildStep.ts
index b253452..284953f 100644
--- a/postBuildStep.ts
+++ b/postBuildStep.ts
@@ -10,6 +10,7 @@ import {
     applyAppendTabPatch,
     applyCommonRevealerPatch,
     applyDrawerTabLocationPatch,
+    applyHandleActionPatch,
     applyInspectorCommonContextMenuPatch,
     applyInspectorCommonCssPatch,
     applyInspectorCommonCssRightToolbarPatch,
@@ -114,6 +115,8 @@ async function patchFilesForWebView(toolsOutDir: string, debugMode: boolean) {
             applyShowElementsTab,
             applyShowRequestBlockingTab,
         ]);
+        await patchFileForWebView("quick_open/QuickOpen.js", toolsOutDir, true, [applyHandleActionPatch]);
+        await patchFileForWebView("quick_open/CommandMenu.js", toolsOutDir, true, [applyHandleActionPatch]);
     } else {
         // tslint:disable-next-line:no-console
         console.log("Patching files for debug version");
@@ -134,6 +137,8 @@ async function patchFilesForWebView(toolsOutDir: string, debugMode: boolean) {
             applyShowElementsTab,
             applyShowRequestBlockingTab,
         ]);
+        await patchFileForWebView("quick_open/QuickOpen.js", toolsOutDir, true, [applyHandleActionPatch]);
+        await patchFileForWebView("quick_open/CommandMenu.js", toolsOutDir, true, [applyHandleActionPatch]);
         // Debug file versions
         await patchFileForWebView("ui/UIUtils.js", toolsOutDir, false, [applyUIUtilsPatch]);
         await patchFileForWebView("dom_extension/DOMExtension.js", toolsOutDir, false, [applyCreateElementPatch]);
diff --git a/src/host/polyfills/simpleView.ts b/src/host/polyfills/simpleView.ts
index 0a82aab..b4059df 100644
--- a/src/host/polyfills/simpleView.ts
+++ b/src/host/polyfills/simpleView.ts
@@ -36,11 +36,9 @@ export function applyCommonRevealerPatch(content: string) {
     }
 }
 
-// This function is needed for Elements-only version, but we need the drawer
-// for the Request Blocking tool when enabling the Network Panel.
-export function applyInspectorViewHandleActionPatch(content: string) {
-    // This patch removes the ability to open/close the drawer using 'ESC'
-    // and using CTRL + [ or CTRL + ] to navigate between tabs.
+export function applyHandleActionPatch(content: string) {
+    // This patch removes the ability to use the
+    // quick open menu (CTRL + P) and command menu (CTRL + SHIFT + P)
     const pattern = /handleAction\(context,\s*actionId\)\s*{/g;
 
     if (content.match(pattern)) {


Test patch:
diff --git a/src/host/polyfills/simpleView.test.ts b/src/host/polyfills/simpleView.test.ts
index 0878cf6..eba0a1f 100644
--- a/src/host/polyfills/simpleView.test.ts
+++ b/src/host/polyfills/simpleView.test.ts
@@ -37,16 +37,26 @@ describe("simpleView", () => {
             expect.stringContaining("let reveal = function revealInVSCode(revealable, omitFocus) {"));
     });
 
-    it("applyInspectorViewPatch correctly changes handleAction text", async () => {
+    it("applyHandleActionPatch correctly changes handleAction text", async () => {
         const comparableText = "handleAction(context, actionId) {\n";
-        let fileContents = getTextFromFile("ui/InspectorView.js");
+        const apply = await import("./simpleView");
+
+        let fileContents = getTextFromFile("quick_open/QuickOpen.js");
         // The file was not found, so test that at least the text is being replaced.
         fileContents = fileContents ? fileContents : comparableText;
 
-        const apply = await import("./simpleView");
-        const result = apply.applyInspectorViewHandleActionPatch(fileContents);
-        expect(result).not.toEqual(null);
-        expect(result).toEqual(
+        const quickOpenResult = apply.applyHandleActionPatch(fileContents);
+        expect(quickOpenResult).not.toEqual(null);
+        expect(quickOpenResult).toEqual(
+            expect.stringContaining("handleAction(context, actionId) { return false;"));
+
+        fileContents = getTextFromFile("quick_open/CommandMenu.js");
+        // The file was not found, so test that at least the text is being replaced.
+        fileContents = fileContents ? fileContents : comparableText;
+
+        const commandMenuResult = apply.applyHandleActionPatch(fileContents);
+        expect(commandMenuResult).not.toEqual(null);
+        expect(commandMenuResult).toEqual(
             expect.stringContaining("handleAction(context, actionId) { return false;"));
     });