From fb9f2ed3170e66a5ed5cdd1226e7de2005461965 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Mon, 11 Jan 2021 16:18:56 -0700 Subject: [PATCH] fix(search): Ensure that opened windows are sorted before any other launcher options --- src/dialog_launcher.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/dialog_launcher.ts b/src/dialog_launcher.ts index 6e0d2c70..39ad80cc 100644 --- a/src/dialog_launcher.ts +++ b/src/dialog_launcher.ts @@ -60,6 +60,8 @@ export class Launcher extends search.Search { this.last_plugin = null + let windows = new Array() + this.service.query(pattern, (plugin, response) => { if (response.event === "queried") { for (const selection of response.selections) { @@ -97,7 +99,7 @@ export class Launcher extends search.Search { || contains_pattern(window.meta.get_title(), needles); if (retain) { - this.options.push(window_selection(ext, window, this.icon_size())) + windows.push(window_selection(ext, window, this.icon_size())) } } @@ -123,8 +125,7 @@ export class Launcher extends search.Search { } } - // Sort the list of matched selections - this.options.sort((a, b) => { + const sorter = (a: launch.SearchOption, b: launch.SearchOption) => { const a_name = a.title.toLowerCase() const b_name = b.title.toLowerCase() @@ -143,7 +144,12 @@ export class Launcher extends search.Search { } return a_name_weight > b_name_weight ? 1 : 0 - }); + } + + // Sort the list of matched selections + windows.sort(sorter) + this.options.sort(sorter); + this.options = windows.concat(this.options) // Truncate excess items from the list this.options.splice(this.list_max());