From 1e0ba65f3c0f555abe7b053ab5dabb70cece744c Mon Sep 17 00:00:00 2001 From: Sean T Fitzgerald Date: Tue, 12 Nov 2013 18:30:33 -0500 Subject: [PATCH 1/7] Added ESC, Y, A, N, and S as keyboard shortcuts to the Replace and Find function. --- Run | 0 src/search/FindReplace.js | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 Run diff --git a/Run b/Run new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/search/FindReplace.js b/src/search/FindReplace.js index 3b900de4850..1aa62271019 100644 --- a/src/search/FindReplace.js +++ b/src/search/FindReplace.js @@ -572,6 +572,30 @@ define(function (require, exports, module) { modalBar = null; } }); + modalBar.getRoot().on("keyup", function (e) { + if (e.keyCode == 27 /*ESC*/ || e.keyCode == 89 /*Y*/ || e.keyCode == 65 /*A*/ || e.keyCode == 78 /*N*/ || e.keyCode == 83 /*S*/) { + if (e.keyCode == 27) { + modalBar.prepareClose(); + modalBar.close(); + } + if (e.keyCode == 89) { + doReplace(match); + } + if (e.keyCode == 65) { + _showReplaceAllPanel(editor, query, text); + } + if (e.keyCode == 78) { + advance(); + } + if (e.keyCode == 83) { + modalBar.prepareClose(); + modalBar.close(); + } + } + // if (e.keyCode == 89) + // doReplace(match); + // } + }); }; var doReplace = function (match) { cursor.replace(typeof query === "string" ? text : parseDollars(text, match)); From 9968174ff07d45d796404bf48d73cba362c9b7a9 Mon Sep 17 00:00:00 2001 From: Sean T Fitzgerald Date: Tue, 12 Nov 2013 18:56:42 -0500 Subject: [PATCH 2/7] replaced == with === --- src/search/FindReplace.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/search/FindReplace.js b/src/search/FindReplace.js index 1aa62271019..8ce6e65ffac 100644 --- a/src/search/FindReplace.js +++ b/src/search/FindReplace.js @@ -574,20 +574,20 @@ define(function (require, exports, module) { }); modalBar.getRoot().on("keyup", function (e) { if (e.keyCode == 27 /*ESC*/ || e.keyCode == 89 /*Y*/ || e.keyCode == 65 /*A*/ || e.keyCode == 78 /*N*/ || e.keyCode == 83 /*S*/) { - if (e.keyCode == 27) { + if (e.keyCode === 27) { modalBar.prepareClose(); modalBar.close(); } - if (e.keyCode == 89) { + if (e.keyCode === 89) { doReplace(match); } - if (e.keyCode == 65) { + if (e.keyCode === 65) { _showReplaceAllPanel(editor, query, text); } - if (e.keyCode == 78) { + if (e.keyCode === 78) { advance(); } - if (e.keyCode == 83) { + if (e.keyCode === 83) { modalBar.prepareClose(); modalBar.close(); } From e5c84b5d89996fdd4ccbca9bda46de0bf4f56c43 Mon Sep 17 00:00:00 2001 From: Sean T Fitzgerald Date: Tue, 12 Nov 2013 19:09:39 -0500 Subject: [PATCH 3/7] Missed a couple '=='s. Theya re replaced now so it should pass the Travis tests. --- src/search/FindReplace.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search/FindReplace.js b/src/search/FindReplace.js index 8ce6e65ffac..6238ebe291b 100644 --- a/src/search/FindReplace.js +++ b/src/search/FindReplace.js @@ -573,7 +573,7 @@ define(function (require, exports, module) { } }); modalBar.getRoot().on("keyup", function (e) { - if (e.keyCode == 27 /*ESC*/ || e.keyCode == 89 /*Y*/ || e.keyCode == 65 /*A*/ || e.keyCode == 78 /*N*/ || e.keyCode == 83 /*S*/) { + if (e.keyCode === 27 /*ESC*/ || e.keyCode === 89 /*Y*/ || e.keyCode === 65 /*A*/ || e.keyCode === 78 /*N*/ || e.keyCode === 83 /*S*/) { if (e.keyCode === 27) { modalBar.prepareClose(); modalBar.close(); From 5c46759b62bd7df8556045ac0e5361abff857498 Mon Sep 17 00:00:00 2001 From: Sean T Fitzgerald Date: Wed, 13 Nov 2013 09:22:46 -0500 Subject: [PATCH 4/7] Changed the Hard-Coded values to KeyEvent's. Added KeyEvent require to the top. --- Run | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Run diff --git a/Run b/Run deleted file mode 100644 index e69de29bb2d..00000000000 From 0ac34a360f77ec5544fde5dde85e403ad1b24afa Mon Sep 17 00:00:00 2001 From: Sean T Fitzgerald Date: Wed, 13 Nov 2013 15:40:32 -0500 Subject: [PATCH 5/7] Implemented a switch instead of cascading if statements --- src/search/FindReplace.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/search/FindReplace.js b/src/search/FindReplace.js index 6238ebe291b..b5284719388 100644 --- a/src/search/FindReplace.js +++ b/src/search/FindReplace.js @@ -42,6 +42,7 @@ define(function (require, exports, module) { StringUtils = require("utils/StringUtils"), Editor = require("editor/Editor"), EditorManager = require("editor/EditorManager"), + KeyEvent = require("utils/KeyEvent"), ModalBar = require("widgets/ModalBar").ModalBar, ScrollTrackMarkers = require("search/ScrollTrackMarkers"), PanelManager = require("view/PanelManager"), @@ -573,28 +574,26 @@ define(function (require, exports, module) { } }); modalBar.getRoot().on("keyup", function (e) { - if (e.keyCode === 27 /*ESC*/ || e.keyCode === 89 /*Y*/ || e.keyCode === 65 /*A*/ || e.keyCode === 78 /*N*/ || e.keyCode === 83 /*S*/) { - if (e.keyCode === 27) { - modalBar.prepareClose(); + switch(e.keyCode) + { + case KeyEvent.DOM_VK_ESCAPE: modalBar.close(); - } - if (e.keyCode === 89) { + break; + case KeyEvent.DOM_VK_Y: doReplace(match); - } - if (e.keyCode === 65) { + break; + case KeyEvent.DOM_VK_A: _showReplaceAllPanel(editor, query, text); - } - if (e.keyCode === 78) { + break; + case KeyEvent.DOM_VK_N: advance(); - } - if (e.keyCode === 83) { - modalBar.prepareClose(); + break; + case KeyEvent.DOM_VK_S: modalBar.close(); - } + break; + default: + break; } - // if (e.keyCode == 89) - // doReplace(match); - // } }); }; var doReplace = function (match) { From c295efe4dbc79ecfa61313e763f75d61d45a18ce Mon Sep 17 00:00:00 2001 From: Sean T Fitzgerald Date: Wed, 13 Nov 2013 15:47:54 -0500 Subject: [PATCH 6/7] fixing Travis CI tests --- src/search/FindReplace.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/search/FindReplace.js b/src/search/FindReplace.js index b5284719388..3bda7c9c37a 100644 --- a/src/search/FindReplace.js +++ b/src/search/FindReplace.js @@ -576,23 +576,23 @@ define(function (require, exports, module) { modalBar.getRoot().on("keyup", function (e) { switch(e.keyCode) { - case KeyEvent.DOM_VK_ESCAPE: - modalBar.close(); - break; - case KeyEvent.DOM_VK_Y: - doReplace(match); - break; - case KeyEvent.DOM_VK_A: - _showReplaceAllPanel(editor, query, text); - break; - case KeyEvent.DOM_VK_N: - advance(); - break; - case KeyEvent.DOM_VK_S: - modalBar.close(); - break; - default: - break; + case KeyEvent.DOM_VK_ESCAPE: + modalBar.close(); + break; + case KeyEvent.DOM_VK_Y: + doReplace(match); + break; + case KeyEvent.DOM_VK_A: + _showReplaceAllPanel(editor, query, text); + break; + case KeyEvent.DOM_VK_N: + advance(); + break; + case KeyEvent.DOM_VK_S: + modalBar.close(); + break; + default: + break; } }); }; From 5cc9fa9d42637493a94ca5b8af79421fbdbdbfff Mon Sep 17 00:00:00 2001 From: Sean T Fitzgerald Date: Sun, 17 Nov 2013 15:57:50 -0500 Subject: [PATCH 7/7] JSLint'ed the code to fix the swithc statement. Removed the unnecessary default case. --- src/search/FindReplace.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/search/FindReplace.js b/src/search/FindReplace.js index 3bda7c9c37a..74bb8726420 100644 --- a/src/search/FindReplace.js +++ b/src/search/FindReplace.js @@ -574,8 +574,7 @@ define(function (require, exports, module) { } }); modalBar.getRoot().on("keyup", function (e) { - switch(e.keyCode) - { + switch (e.keyCode) { case KeyEvent.DOM_VK_ESCAPE: modalBar.close(); break; @@ -591,8 +590,6 @@ define(function (require, exports, module) { case KeyEvent.DOM_VK_S: modalBar.close(); break; - default: - break; } }); };