From 435b220340452ef2b2b1614d0012c8229b45eac7 Mon Sep 17 00:00:00 2001 From: abose Date: Thu, 11 Jan 2024 19:43:27 +0530 Subject: [PATCH 1/2] chore: reverse highlight should also be disabled when live preview highlight feature deisabled --- .../MultiBrowserImpl/protocol/LiveDevProtocol.js | 6 ++++++ src/phoenix/shell.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js b/src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js index db96a2a37..9ac87998c 100644 --- a/src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js +++ b/src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js @@ -47,6 +47,7 @@ define(function (require, exports, module) { RemoteFunctions = require("text!LiveDevelopment/BrowserScripts/RemoteFunctions.js"), EditorManager = require("editor/EditorManager"), LiveDevMultiBrowser = require("LiveDevelopment/LiveDevMultiBrowser"), + PreferencesManager = require("preferences/PreferencesManager"), HTMLInstrumentation = require("LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation"), StringUtils = require("utils/StringUtils"), FileViewController = require("project/FileViewController"); @@ -94,6 +95,11 @@ define(function (require, exports, module) { } function _tagSelectedInLivePreview(tagId) { + const highlightPref = PreferencesManager.getViewState("livedev.highlight"); + if(!highlightPref){ + // live preview highlight and reverse highlight feature is disabled + return; + } const liveDoc = LiveDevMultiBrowser.getCurrentLiveDoc(), editor = EditorManager.getActiveEditor(); const liveDocPath = liveDoc ? liveDoc.doc.file.fullPath : null, diff --git a/src/phoenix/shell.js b/src/phoenix/shell.js index 3ca684135..9eb3a1ec0 100644 --- a/src/phoenix/shell.js +++ b/src/phoenix/shell.js @@ -118,6 +118,9 @@ Phoenix.app = { return window.Strings.STORED_IN_YOUR_BROWSER; }, getDisplayPath: function (fullOrRelativeVFSPath) { + if(!fullOrRelativeVFSPath){ + return ""; + } // reruns a path that can be shown to the user to make some sense of the virtual file path. // The returned path is platform path for tauri, // a relative path of the form (folder/file.txt) starting with opened folder name for fs access- /mnt/paths From 729795413425714039f2fc80b72f2a65dbe684ce Mon Sep 17 00:00:00 2001 From: abose Date: Thu, 11 Jan 2024 20:00:18 +0530 Subject: [PATCH 2/2] chore: reverse highlight disable integration tests --- test/spec/LiveDevelopmentMultiBrowser-test.js | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/test/spec/LiveDevelopmentMultiBrowser-test.js b/test/spec/LiveDevelopmentMultiBrowser-test.js index 305e854a8..a9df267a0 100644 --- a/test/spec/LiveDevelopmentMultiBrowser-test.js +++ b/test/spec/LiveDevelopmentMultiBrowser-test.js @@ -54,7 +54,8 @@ define(function (require, exports, module) { CommandManager, BeautificationManager, Commands, - WorkspaceManager; + WorkspaceManager, + PreferencesManager; let testFolder = SpecRunnerUtils.getTestPath("/spec/LiveDevelopment-MultiBrowser-test-files"), prettierTestFolder = SpecRunnerUtils.getTestPath("/spec/prettier-test-files"), @@ -93,6 +94,7 @@ define(function (require, exports, module) { EditorManager = brackets.test.EditorManager; WorkspaceManager = brackets.test.WorkspaceManager; BeautificationManager = brackets.test.BeautificationManager; + PreferencesManager = brackets.test.PreferencesManager; await SpecRunnerUtils.loadProjectInTestWindow(testFolder); if(!WorkspaceManager.isPanelVisible('live-preview-panel')){ @@ -112,7 +114,11 @@ define(function (require, exports, module) { EditorManager = null; }, 30000); + async function _enableLiveHighlights(enable) { + PreferencesManager.setViewState("livedev.highlight", enable); + } async function endPreviewSession() { + await _enableLiveHighlights(true); LiveDevMultiBrowser.close(); await awaitsForDone(CommandManager.execute(Commands.FILE_CLOSE_ALL, { _forceClose: true }), "closing all file"); @@ -756,6 +762,28 @@ define(function (require, exports, module) { await endPreviewSession(); }, 30000); + it("should reverse highlight be disabled if live highlight is disabled", async function () { + await _enableLiveHighlights(false); + await awaitsForDone(SpecRunnerUtils.openProjectFiles(["simple1.html"]), + "SpecRunnerUtils.openProjectFiles simple1.html"); + + await waitsForLiveDevelopmentToOpen(); + let editor = EditorManager.getActiveEditor(); + editor && editor.setCursorPos({ line: 0, ch: 0 }); + + await awaits(500); + await forRemoteExec(`document.getElementsByClassName("__brackets-ld-highlight").length`, (result)=>{ + return result === 0; + }); + await forRemoteExec(`document.getElementById("testId2").click()`); + + await awaits(500); + expect(editor.getCursorPos()).toEql({ line: 0, ch: 0, sticky: null }); + + await _enableLiveHighlights(true); + await endPreviewSession(); + }, 30000); + it("should ctrl-s to save page be disabled inside live preview iframes", async function () { await awaitsForDone(SpecRunnerUtils.openProjectFiles(["simple1.html"]), "SpecRunnerUtils.openProjectFiles simple1.html");