Skip to content

Commit

Permalink
[search addon] Add commands to find next/prev with persistent dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
40thieves authored and marijnh committed Jun 7, 2016
1 parent b7b4269 commit 440395d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion addon/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
}
}

function doSearch(cm, rev, persistent) {
function doSearch(cm, rev, persistent, immediate) {
var state = getSearchState(cm);
if (state.query) return findNext(cm, rev);
var q = cm.getSelection() || state.lastQuery;
Expand Down Expand Up @@ -146,6 +146,10 @@
searchNext(query, event);
}
});
if (immediate) {
startSearch(cm, state, q);
findNext(cm, rev);
}
} else {
dialog(cm, queryDialog, "Search for:", q, function(query) {
if (query && !state.query) cm.operation(function() {
Expand Down Expand Up @@ -235,6 +239,8 @@

CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);};
CodeMirror.commands.findPersistentNext = function(cm) {doSearch(cm, false, true, true);};
CodeMirror.commands.findPersistentPrev = function(cm) {doSearch(cm, true, true, true);};
CodeMirror.commands.findNext = doSearch;
CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
CodeMirror.commands.clearSearch = clearSearch;
Expand Down

0 comments on commit 440395d

Please sign in to comment.