Skip to content

Commit

Permalink
* Fixed history list support for find in files
Browse files Browse the repository at this point in the history
* Fixed undo bug for the syntax highlighted textbox
  • Loading branch information
Ruben Daniels committed May 9, 2012
1 parent ec1a40c commit 56983c0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
10 changes: 8 additions & 2 deletions plugins-client/ext.searchinfiles/searchinfiles.js
Expand Up @@ -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
Expand All @@ -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;
});

Expand Down
22 changes: 11 additions & 11 deletions plugins-client/ext.searchreplace/libsearch.js
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -64,7 +64,7 @@ module.exports = {
return true;
},

hasCursorOnLastLine : function(){
hasCursorOnLastLine : function(txtFind){
var selection = window.getSelection();
if (selection.anchorNode.nodeType == 1)
return true;
Expand All @@ -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()") || "[]");

Expand Down Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions plugins-client/ext.searchreplace/searchreplace.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 56983c0

Please sign in to comment.