Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Added ESC, Y, A, N, and S as keyboard shortcuts to the Replace and Find ... #5969

Closed
wants to merge 7 commits into from
20 changes: 20 additions & 0 deletions src/search/FindReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -572,6 +573,25 @@ define(function (require, exports, module) {
modalBar = null;
}
});
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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a switch would make this code block cleaner. And you don't really need the first If, if you are then handling each keyCode in it's own if.

});
};
var doReplace = function (match) {
cursor.replace(typeof query === "string" ? text : parseDollars(text, match));
Expand Down