diff --git a/src/search/FindInFiles.js b/src/search/FindInFiles.js index dcb512ccc75..05d0612ae59 100644 --- a/src/search/FindInFiles.js +++ b/src/search/FindInFiles.js @@ -810,6 +810,13 @@ define(function (require, exports, module) { var currentEditor = EditorManager.getActiveEditor(), initialString = currentEditor && currentEditor.getSelectedText(); + if (dialog && !dialog.closed && dialog.hasOwnProperty("modalBar") && dialog.modalBar) { + // The modalBar was already up. When creating the new modalBar, copy the + // current query instead of using the passed-in selected text. + initialString = dialog.getDialogTextField().val(); + dialog.modalBar.close(true, false); + } + dialog = new FindInFilesDialog(); searchResults = {}; currentStart = 0;