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>
|
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
||||||
* Julian Viereck <julian.viereck@gmail.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
|
* 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
|
* 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)
|
if (this.$selectionOccurrences.length)
|
||||||
this.clearSelectionHighlight();
|
this.clearSelectionHighlight();
|
||||||
|
|
||||||
var selectedRange = this.getSelectionRange();
|
var selection = this.getSelectionRange();
|
||||||
if (selectedRange.isEmpty())
|
if (selection.isEmpty() || selection.isMultiLine())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var newOptions = {wrap:true, wholeWord: true};
|
var startOuter = selection.start.column - 1;
|
||||||
newOptions.needle = this.session.getTextRange(selectedRange);
|
var endOuter = selection.end.column + 1;
|
||||||
if (!newOptions.needle)
|
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;
|
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();
|
var currentOptions = this.$search.getOptions();
|
||||||
this.$search.set(newOptions);
|
this.$search.set(newOptions);
|
||||||
|
|
||||||
var ranges = this.$search.findAll(this.session);
|
var ranges = this.$search.findAll(this.session);
|
||||||
this.$selectionOccurrences = [];
|
this.$selectionOccurrences = [];
|
||||||
ranges.forEach(function(range) {
|
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.$selectionOccurrences.push(this.renderer.addMarker(range, "ace_selected_word"));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
|
@ -356,7 +374,7 @@ var Editor =function(renderer, session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onCursorChange(e);
|
this.onCursorChange(e);
|
||||||
this.clearSelectionHighlight();
|
this.highlightSelection();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onDocumentChangeBreakpoint = function() {
|
this.onDocumentChangeBreakpoint = function() {
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,6 @@ var MouseHandler = function(editor) {
|
||||||
|
|
||||||
this.onMouseDoubleClick = function(e) {
|
this.onMouseDoubleClick = function(e) {
|
||||||
this.editor.selection.selectWord();
|
this.editor.selection.selectWord();
|
||||||
this.editor.highlightSelection();
|
|
||||||
this.$clickSelection = this.editor.getSelectionRange();
|
this.$clickSelection = this.editor.getSelectionRange();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue