Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #4878 from lkcampbell/fix-issue-4778
Browse files Browse the repository at this point in the history
Fix issue 4778: Do not show Active Line Highlight when editor has selection
  • Loading branch information
RaymondLim committed Aug 23, 2013
2 parents 55e0995 + aea644d commit 5829ef7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
28 changes: 26 additions & 2 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,25 @@ define(function (require, exports, module) {
}
}
}


/**
* @private
* Handle any cursor movement in editor, including selecting and unselecting text.
* @param {jQueryObject} jqEvent jQuery event object
* @param {Editor} editor Current, focused editor (main or inline)
* @param {!Event} event
*/
function _handleCursorActivity(jqEvent, editor, event) {
// If there is a selection in the editor, temporarily hide Active Line Highlight
if (editor.hasSelection()) {
if (editor._codeMirror.getOption("styleActiveLine")) {
editor._codeMirror.setOption("styleActiveLine", false);
}
} else {
editor._codeMirror.setOption("styleActiveLine", _styleActiveLine);
}
}

function _handleKeyEvents(jqEvent, editor, event) {
_checkElectricChars(jqEvent, editor, event);

Expand Down Expand Up @@ -382,6 +400,7 @@ define(function (require, exports, module) {
this._installEditorListeners();

$(this)
.on("cursorActivity", _handleCursorActivity)
.on("keyEvent", _handleKeyEvents)
.on("change", this._handleEditorChange.bind(this));

Expand Down Expand Up @@ -1550,10 +1569,15 @@ 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.setShowActiveLine = function (value, editor) {
_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
3 changes: 2 additions & 1 deletion src/editor/EditorOptionHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ define(function (require, exports, module) {

var AppInit = require("utils/AppInit"),
Editor = require("editor/Editor").Editor,
EditorManager = require("editor/EditorManager"),
Commands = require("command/Commands"),
CommandManager = require("command/CommandManager"),
Strings = require("strings");
Expand All @@ -48,7 +49,7 @@ define(function (require, exports, module) {
* Activates/Deactivates showing active line option
*/
function _toggleActiveLine() {
Editor.setShowActiveLine(!Editor.getShowActiveLine());
Editor.setShowActiveLine(!Editor.getShowActiveLine(), EditorManager.getCurrentFullEditor());
CommandManager.get(Commands.TOGGLE_ACTIVE_LINE).setChecked(Editor.getShowActiveLine());
}

Expand Down

0 comments on commit 5829ef7

Please sign in to comment.