Skip to content
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

chore: reverse highlight should also be disabled when live preview highlight feature deisabled #1287

Merged
merged 2 commits into from
Jan 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/phoenix/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 29 additions & 1 deletion test/spec/LiveDevelopmentMultiBrowser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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')){
Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
Loading