Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
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
15 changes: 9 additions & 6 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,14 @@ define(function (require, exports, module) {
function _setEditorOption(value, cmOption) {
_instances.forEach(function (editor) {
editor._codeMirror.setOption(cmOption, value);

// If there is a selection in the editor, temporarily hide Active Line Highlight
if ((cmOption === "styleActiveLine") && (value === true)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to have this here since it takes care of all editors, not just the main editor that you took care of in your previous implementation.

if (editor.hasSelection()) {
editor._codeMirror.setOption("styleActiveLine", false);
}
}

$(editor).triggerHandler("optionChange", [cmOption, value]);
});
}
Expand Down Expand Up @@ -1569,15 +1577,10 @@ define(function (require, exports, module) {
/**
* Sets show active line option and reapply it to all open editors.
* @param {boolean} value
* @param {Editor} editor Current, focused editor (main or inline)
*/
Editor.setShowActiveLine = function (value, editor) {
Editor.setShowActiveLine = function (value) {
_styleActiveLine = value;
_setEditorOptionAndPref(value, "styleActiveLine", "styleActiveLine");

if (editor.hasSelection()) {
editor._codeMirror.setOption("styleActiveLine", false);
}
};

/** @type {boolean} Returns true if show active line is enabled for all editors */
Expand Down
2 changes: 1 addition & 1 deletion src/editor/EditorOptionHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ define(function (require, exports, module) {
* Activates/Deactivates showing active line option
*/
function _toggleActiveLine() {
Editor.setShowActiveLine(!Editor.getShowActiveLine(), EditorManager.getCurrentFullEditor());
Editor.setShowActiveLine(!Editor.getShowActiveLine());
CommandManager.get(Commands.TOGGLE_ACTIVE_LINE).setChecked(Editor.getShowActiveLine());
}

Expand Down
17 changes: 17 additions & 0 deletions test/spec/EditorOptionHandlers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ define(function (require, exports, module) {
});
}

function checkActiveLineOption(editor, shouldBe) {
runs(function () {
expect(editor).toBeTruthy();
expect(editor._codeMirror.getOption("styleActiveLine")).toBe(shouldBe);
});
}

function checkLineNumbers(editor, shouldShow) {
runs(function () {
var gutterElement, $lineNumbers;
Expand Down Expand Up @@ -270,6 +277,16 @@ define(function (require, exports, module) {
});
});

it("should have the active line option be FALSE when the editor has a selection", function () {
openEditor(CSS_FILE);

runs(function () {
var editor = EditorManager.getCurrentFullEditor();
editor.setSelection({line: 0, ch: 0}, {line: 0, ch: 1});
checkActiveLineOption(editor, false);
});
});

it("should style the active line when opening another document with show active line on", function () {
openEditor(CSS_FILE);
openAnotherEditor(HTML_FILE);
Expand Down