From 267c0104daf1885a6a07a23de72b69b2b34fe593 Mon Sep 17 00:00:00 2001 From: Chema Date: Fri, 26 Oct 2012 02:58:04 +0200 Subject: [PATCH] Populates the replace input with the currently selected text --- src/search/FindReplace.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/search/FindReplace.js b/src/search/FindReplace.js index 2873191a447..6ae3a655f26 100644 --- a/src/search/FindReplace.js +++ b/src/search/FindReplace.js @@ -184,9 +184,14 @@ define(function (require, exports, module) { findFirst(getDialogTextField().attr("value")); }); } + + function getCurrentEditorSelectedText() { + var currentEditor = EditorManager.getFocusedEditor(); + return (currentEditor && currentEditor.getSelectedText()) || ""; + } var replaceQueryDialog = Strings.CMD_REPLACE + - ': (' + + ': (' + Strings.SEARCH_REGEXP_INFO + ')'; var replacementQueryDialog = Strings.WITH + ': '; @@ -198,7 +203,7 @@ define(function (require, exports, module) { ' ' + Strings.BUTTON_STOP + ''; function replace(cm, all) { - dialog(cm, replaceQueryDialog, Strings.CMD_REPLACE, function (query) { + dialog(cm, replaceQueryDialog.replace("{{SELECTION}}", getCurrentEditorSelectedText()), Strings.CMD_REPLACE, function (query) { if (!query) { return; }