add findall command

This commit is contained in:
nightwing 2014-04-13 20:47:06 +04:00
commit 14721de01f
2 changed files with 12 additions and 1 deletions

View file

@ -80,6 +80,11 @@ exports.defaultCommands = [{
name: "alignCursors",
exec: function(editor) { editor.alignCursors(); },
bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"}
}, {
name: "findAll",
exec: function(editor) { editor.findAll(); },
bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
readonly: true
}];
// commands active only in multiselect mode

View file

@ -578,8 +578,14 @@ var Editor = require("./editor").Editor;
this.findAll = function(needle, options, additive) {
options = options || {};
options.needle = needle || options.needle;
if (options.needle == undefined) {
var range = this.selection.isEmpty()
? this.selection.getWordRange()
: this.selection.getRange();
options.needle = this.session.getTextRange(range);
}
this.$search.set(options);
var ranges = this.$search.findAll(this.session);
if (!ranges.length)
return 0;