From 56983c03095442f2bc2f6f20908293592862c9c6 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 9 May 2012 00:28:47 -0700 Subject: [PATCH] * Fixed history list support for find in files * Fixed undo bug for the syntax highlighted textbox --- .../ext.searchinfiles/searchinfiles.js | 10 +++++++-- plugins-client/ext.searchreplace/libsearch.js | 22 +++++++++---------- .../ext.searchreplace/searchreplace.js | 4 ++-- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/plugins-client/ext.searchinfiles/searchinfiles.js b/plugins-client/ext.searchinfiles/searchinfiles.js index 946a06dd167..9881de34122 100644 --- a/plugins-client/ext.searchinfiles/searchinfiles.js +++ b/plugins-client/ext.searchinfiles/searchinfiles.js @@ -116,8 +116,14 @@ module.exports = ext.register("ext/searchinfiles/searchinfiles", apf.extend({ return false; } - if (_self.findKeyboardHandler(e, "searchfiles", this) === false) + if (_self.findKeyboardHandler(e, "searchfiles", this, chkSFRegEx) === false) return false; + + if (chkSFRegEx.checked + && _self.evaluateRegExp(txtSFFind, tooltipSearchInFiles, + winSearchInFiles, e.htmlEvent) === false) { + return; + } }); txtSFFind.addEventListener("keyup", function(e) { if (e.keyCode != 8 && (e.ctrlKey || e.shiftKey || e.metaKey @@ -136,7 +142,7 @@ module.exports = ext.register("ext/searchinfiles/searchinfiles", apf.extend({ return false; } - if (_self.findKeyboardHandler(e, "replacefiles", this) === false) + if (_self.findKeyboardHandler(e, "replacefiles", this, chkSFRegEx) === false) return false; }); diff --git a/plugins-client/ext.searchreplace/libsearch.js b/plugins-client/ext.searchreplace/libsearch.js index a4ce67cad6d..b9301ecce6e 100644 --- a/plugins-client/ext.searchreplace/libsearch.js +++ b/plugins-client/ext.searchreplace/libsearch.js @@ -11,7 +11,7 @@ var settings = require("core/settings"); var prefix = "search/" module.exports = { - findKeyboardHandler : function(e, listName, txtFind){ + findKeyboardHandler : function(e, listName, txtFind, chkRegEx){ switch (e.keyCode){ case 27: //ESCAPE this.toggleDialog(-1); @@ -22,29 +22,29 @@ module.exports = { e.stop(); return false; case 38: //UP - if (!this.hasCursorOnFirstLine()) + if (!this.hasCursorOnFirstLine(txtFind)) return; - this.navigateList("prev", listName, txtFind); + this.navigateList("prev", listName, txtFind, chkRegEx); return false; case 40: //DOWN - if (!this.hasCursorOnLastLine()) + if (!this.hasCursorOnLastLine(txtFind)) return; - this.navigateList("next", listName, txtFind); + this.navigateList("next", listName, txtFind, chkRegEx); return false; case 36: //HOME if (!e.ctrlKey) return; - this.navigateList("first", listName, txtFind); + this.navigateList("first", listName, txtFind, chkRegEx); return false; case 35: //END if (!e.ctrlKey) return; - this.navigateList("last", listName, txtFind); + this.navigateList("last", listName, txtFind, chkRegEx); return false; } }, - hasCursorOnFirstLine : function(){ + hasCursorOnFirstLine : function(txtFind){ var selection = window.getSelection(); if (selection.anchorNode.nodeType == 1) return true; @@ -64,7 +64,7 @@ module.exports = { return true; }, - hasCursorOnLastLine : function(){ + hasCursorOnLastLine : function(txtFind){ var selection = window.getSelection(); if (selection.anchorNode.nodeType == 1) return true; @@ -84,7 +84,7 @@ module.exports = { return true; }, - navigateList : function(type, listName, txtFind){ + navigateList : function(type, listName, txtFind, chkRegEx){ var model = settings.model; var lines = JSON.parse(model.queryValue(prefix + listName + "/text()") || "[]"); @@ -225,7 +225,7 @@ module.exports = { txtFind.$undo.push(undoItem); } else { - if (!txtFind.$undo.length) + if (txtFind.$undo.length < 2) return; txtFind.$redo.push(txtFind.$undo.pop()); var undoItem = txtFind.$undo[txtFind.$undo.length - 1]; diff --git a/plugins-client/ext.searchreplace/searchreplace.js b/plugins-client/ext.searchreplace/searchreplace.js index fed732bb7d9..6bc699e576d 100644 --- a/plugins-client/ext.searchreplace/searchreplace.js +++ b/plugins-client/ext.searchreplace/searchreplace.js @@ -201,7 +201,7 @@ module.exports = ext.register("ext/searchreplace/searchreplace", apf.extend({ var ace = _self.$getAce(); var isTooLong = ace.getSession().getDocument().getLength() > MAX_LINES; - if (_self.findKeyboardHandler(e, "search", this) === false) { + if (_self.findKeyboardHandler(e, "search", this, chkRegEx) === false) { apf.layout.forceResize(); if (!isTooLong) _self.updateCounter(null, true); @@ -237,7 +237,7 @@ module.exports = ext.register("ext/searchreplace/searchreplace", apf.extend({ return false; } - if (_self.findKeyboardHandler(e, "replace", this) === false) { + if (_self.findKeyboardHandler(e, "replace", this, chkRegEx) === false) { apf.layout.forceResize(); return false; }