diff --git a/src/search/FindInFiles.js b/src/search/FindInFiles.js index adf2b75ea6c..6673efc93fc 100644 --- a/src/search/FindInFiles.js +++ b/src/search/FindInFiles.js @@ -90,6 +90,9 @@ define(function (require, exports, module) { /** @type {Panel} Bottom panel holding the search results. Initialized in htmlReady() */ var searchResultsPanel; + /** @type {Entry} the File selected on the initial search */ + var selectedEntry; + /** @type {number} The index of the first result that is displayed */ var currentStart = 0; @@ -260,9 +263,7 @@ define(function (require, exports, module) { * Sorts the file keys to show the results from the selected file first and the rest sorted by path */ function _sortResultFiles() { - var selectedEntry = ProjectManager.getSelectedItem().fullPath; searchFiles = Object.keys(searchResults); - searchFiles.sort(function (key1, key2) { if (selectedEntry === key1) { return -1; @@ -935,7 +936,13 @@ define(function (require, exports, module) { initialString = dialog.getDialogTextField().val(); dialog._close(true); } - + + // Save the currently selected file's fullpath if there is one selected and if it is a file + var selectedItem = ProjectManager.getSelectedItem(); + if (selectedItem && !selectedItem.isDirectory) { + selectedEntry = selectedItem.fullPath; + } + dialog = new FindInFilesDialog(); searchResults = {}; currentStart = 0;