Skip to content
Snippets Groups Projects
Commit 82e86ef7 authored by Amin Shali's avatar Amin Shali Committed by Marijn Haverbeke
Browse files

[search addon] Preserve the last search query.

parent 9c524fd0
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@
}
function SearchState() {
this.posFrom = this.posTo = this.query = null;
this.posFrom = this.posTo = this.lastQuery = this.query = null;
this.overlay = null;
}
function getSearchState(cm) {
......@@ -75,7 +75,8 @@
function doSearch(cm, rev) {
var state = getSearchState(cm);
if (state.query) return findNext(cm, rev);
dialog(cm, queryDialog, "Search for:", cm.getSelection(), function(query) {
var q = cm.getSelection() || state.lastQuery;
dialog(cm, queryDialog, "Search for:", q, function(query) {
cm.operation(function() {
if (!query || state.query) return;
state.query = parseQuery(query);
......@@ -104,6 +105,7 @@
});}
function clearSearch(cm) {cm.operation(function() {
var state = getSearchState(cm);
state.lastQuery = state.query;
if (!state.query) return;
state.query = null;
cm.removeOverlay(state.overlay);
......@@ -116,7 +118,8 @@
var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>Stop</button>";
function replace(cm, all) {
if (cm.getOption("readOnly")) return;
dialog(cm, replaceQueryDialog, "Replace:", cm.getSelection(), function(query) {
var q = cm.getSelection() || state.lastQuery;
dialog(cm, replaceQueryDialog, "Replace:", q, function(query) {
if (!query) return;
query = parseQuery(query);
dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment