More fixes.
- Only highlight selected words. - Highlight selected words by keyboard as well, not just mouse double click.
This commit is contained in:
parent
24e1357755
commit
0c959834a8
2 changed files with 25 additions and 8 deletions
|
|
@ -23,6 +23,7 @@
|
|||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
||||
* Julian Viereck <julian.viereck@gmail.com>
|
||||
* Mihai Sucan <mihai.sucan@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
@ -240,22 +241,39 @@ var Editor =function(renderer, session) {
|
|||
if (this.$selectionOccurrences.length)
|
||||
this.clearSelectionHighlight();
|
||||
|
||||
var selectedRange = this.getSelectionRange();
|
||||
if (selectedRange.isEmpty())
|
||||
var selection = this.getSelectionRange();
|
||||
if (selection.isEmpty() || selection.isMultiLine())
|
||||
return;
|
||||
|
||||
var newOptions = {wrap:true, wholeWord: true};
|
||||
newOptions.needle = this.session.getTextRange(selectedRange);
|
||||
if (!newOptions.needle)
|
||||
var startOuter = selection.start.column - 1;
|
||||
var endOuter = selection.end.column + 1;
|
||||
var line = this.session.getLine(selection.start.row);
|
||||
var lineCols = line.length - 1;
|
||||
var needle = line.substring(Math.max(startOuter, 0),
|
||||
Math.min(endOuter, lineCols));
|
||||
|
||||
// Make sure the outer characters are not part of the word.
|
||||
if ((startOuter >= 0 && !/[^\w\d]/.test(needle.charAt(0))) ||
|
||||
(endOuter <= lineCols && !/[^\w\d]/.test(needle.charAt(needle.length - 1))))
|
||||
return;
|
||||
|
||||
needle = line.substring(selection.start.column, selection.end.column);
|
||||
if (!/^[\w\d]+$/.test(needle))
|
||||
return;
|
||||
|
||||
var newOptions = {
|
||||
wrap: true,
|
||||
wholeWord: true,
|
||||
needle: needle,
|
||||
};
|
||||
|
||||
var currentOptions = this.$search.getOptions();
|
||||
this.$search.set(newOptions);
|
||||
|
||||
var ranges = this.$search.findAll(this.session);
|
||||
this.$selectionOccurrences = [];
|
||||
ranges.forEach(function(range) {
|
||||
if (!range.contains(selectedRange.start.row, selectedRange.start.column))
|
||||
if (!range.contains(selection.start.row, selection.start.column))
|
||||
this.$selectionOccurrences.push(this.renderer.addMarker(range, "ace_selected_word"));
|
||||
}, this);
|
||||
|
||||
|
|
@ -356,7 +374,7 @@ var Editor =function(renderer, session) {
|
|||
}
|
||||
|
||||
this.onCursorChange(e);
|
||||
this.clearSelectionHighlight();
|
||||
this.highlightSelection();
|
||||
};
|
||||
|
||||
this.onDocumentChangeBreakpoint = function() {
|
||||
|
|
|
|||
|
|
@ -146,7 +146,6 @@ var MouseHandler = function(editor) {
|
|||
|
||||
this.onMouseDoubleClick = function(e) {
|
||||
this.editor.selection.selectWord();
|
||||
this.editor.highlightSelection();
|
||||
this.$clickSelection = this.editor.getSelectionRange();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue