-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix issue 4778: Do not show Active Line Highlight when editor has selection #4878
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,6 +250,16 @@ define(function (require, exports, module) { | |
} | ||
} | ||
|
||
function _handleCursorActivity(jqEvent, editor, event) { | ||
if (editor.hasSelection()) { | ||
if (editor._codeMirror.getOption("styleActiveLine")) { | ||
editor._codeMirror.setOption("styleActiveLine", false); | ||
} | ||
} else { | ||
editor._codeMirror.setOption("styleActiveLine", _styleActiveLine); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm seeing an issue with Highlight Active Line menu item unchecked after making a selection and then pressing left/right arrow to deselect. Even though we still see the active line being highlighted, the menu item is no longer checked. It seems that Editor.setShowActiveLine gets called at (or after) a selection is made and therefore _styleActiveLine becomes false. Update: My steps above are wrong. You can see the issue with the following steps.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RaymondLim, I haven't been able to repro the problem using the steps you provided. Is there anything else you can provide me to help me recreate the issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lkcampbell There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RaymondLim, sorry I still can't repro the issue with your new steps. The test you are using is very basic so it surprises me that it is failing. It's not like you are jumping around between different main and inline editors or anything complex. Is it possible there is something out of sync with my pull request or your patched machine? I'm going to try loading a fresh build and apply the patch myself and see if I can repro the issue that way. Would it be possible to have someone else try to patch on your end and see if they have the same problem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I strike out the first paragraph that is no longer true with my steps. And actually I should have posted the issue below on line 1570 (which I think is the culprit). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not even looking at the first paragraph and I'm not concerned about the line it was posted on. What I am saying is I do the following steps (from your message above):
And I can't repro the issue. First, we need to address the fact that you can repro problem and I can't. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, my mistake. I was copying over your changes in Editor.js, but not your changes in EditorOptionHandlers.js. That's why I was seeing the issue that you can't reproduce. |
||
} | ||
} | ||
|
||
function _handleKeyEvents(jqEvent, editor, event) { | ||
_checkElectricChars(jqEvent, editor, event); | ||
|
||
|
@@ -382,6 +392,7 @@ define(function (require, exports, module) { | |
this._installEditorListeners(); | ||
|
||
$(this) | ||
.on("cursorActivity", _handleCursorActivity) | ||
.on("keyEvent", _handleKeyEvents) | ||
.on("change", this._handleEditorChange.bind(this)); | ||
|
||
|
@@ -1550,10 +1561,15 @@ define(function (require, exports, module) { | |
/** | ||
* Sets show active line option and reapply it to all open editors. | ||
* @param {boolean} value | ||
* @param {Editor} Current editor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: You need to have the param name |
||
*/ | ||
Editor.setShowActiveLine = function (value) { | ||
Editor.setShowActiveLine = function (value, editor) { | ||
_styleActiveLine = value; | ||
_setEditorOptionAndPref(value, "styleActiveLine", "styleActiveLine"); | ||
|
||
if (editor.hasSelection()) { | ||
editor._codeMirror.setOption("styleActiveLine", false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
update: my mistake. Nothing wrong here. |
||
} | ||
}; | ||
|
||
/** @type {boolean} Returns true if show active line is enabled for all editors */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add JSDocs for the parameters.