[incremental search] fixing when / when not selection should be extended
This commit is contained in:
parent
1daaeb3a79
commit
724193dcbc
2 changed files with 33 additions and 0 deletions
|
|
@ -71,6 +71,7 @@ oop.inherits(IncrementalSearch, Search);
|
||||||
this.$options.needle = '';
|
this.$options.needle = '';
|
||||||
this.$options.backwards = backwards;
|
this.$options.backwards = backwards;
|
||||||
editor.keyBinding.addKeyboardHandler(this.$keyboardHandler);
|
editor.keyBinding.addKeyboardHandler(this.$keyboardHandler);
|
||||||
|
this.selectionFix(editor);
|
||||||
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||||
var msg = this.$options.backwards ? 'reverse-' : '';
|
var msg = this.$options.backwards ? 'reverse-' : '';
|
||||||
msg += 'isearch: ' + this.$options.needle;
|
msg += 'isearch: ' + this.$options.needle;
|
||||||
|
|
@ -83,6 +84,16 @@ oop.inherits(IncrementalSearch, Search);
|
||||||
this.message('');
|
this.message('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.selectionFix = function(editor) {
|
||||||
|
// Fix selection bug: When clicked inside the editor
|
||||||
|
// editor.selection.$isEmpty is false even if the mouse click did not
|
||||||
|
// open a selection. This is interpreted by the move commands to
|
||||||
|
// extend the selection. To only extend the selection when there is
|
||||||
|
// one, we clear it here
|
||||||
|
if (editor.selection.isEmpty() && !editor.session.$emacsMark) {
|
||||||
|
editor.clearSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
this.cancelSearch = function(reset) {
|
this.cancelSearch = function(reset) {
|
||||||
var e = this.$editor;
|
var e = this.$editor;
|
||||||
this.$prevNeedle = this.$options.needle;
|
this.$prevNeedle = this.$options.needle;
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,28 @@ module.exports = {
|
||||||
iSearch.activate(editor);
|
iSearch.activate(editor);
|
||||||
iSearch.next({backwards: false, useCurrentOrPrevSearch: true});
|
iSearch.next({backwards: false, useCurrentOrPrevSearch: true});
|
||||||
assert.position(editor.getCursorPosition(), 1, 5);
|
assert.position(editor.getCursorPosition(), 1, 5);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test: don't extend selection range if selection is empty" : function() {
|
||||||
|
iSearch.activate(editor);
|
||||||
|
iSearch.addChar('1'); iSearch.addChar('2');;
|
||||||
|
testRanges("Range: [0/5] -> [0/5]", [editor.getSelectionRange()], "sel range");
|
||||||
|
},
|
||||||
|
|
||||||
|
"test: extend selection range if selection exists" : function() {
|
||||||
|
iSearch.activate(editor);
|
||||||
|
editor.selection.selectTo(0, 1);
|
||||||
|
iSearch.addChar('1'); iSearch.addChar('2');;
|
||||||
|
testRanges("Range: [0/0] -> [0/5]", [editor.getSelectionRange()], "sel range");
|
||||||
|
},
|
||||||
|
|
||||||
|
"test: extend selection in emacs mark mode" : function() {
|
||||||
|
var emacs = require('ace/keyboard/emacs');
|
||||||
|
editor.keyBinding.addKeyboardHandler(emacs.handler);
|
||||||
|
emacs.handler.commands.setMark.exec(editor);
|
||||||
|
iSearch.activate(editor);
|
||||||
|
iSearch.addChar('1'); iSearch.addChar('2');;
|
||||||
|
testRanges("Range: [0/0] -> [0/5]", [editor.getSelectionRange()], "sel range");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue