diff --git a/lib/select.ts b/lib/select.ts index eb83520..c98a373 100644 --- a/lib/select.ts +++ b/lib/select.ts @@ -14,6 +14,7 @@ import { windows, CHROME } from "./browser"; import { BaseItem } from "./item"; interface BaseMatchedItem extends BaseItem { + sidx?: number; matched?: string | null; prevMatched?: string | null; } @@ -29,6 +30,7 @@ function computeSelection( onlyFast: boolean): ItemDelta[] { let ws = items.map((item, idx: number) => { item.idx = item.idx || idx; + item.sidx = item.sidx || idx; const {matched = null} = item; item.prevMatched = matched; item.matched = null; @@ -52,7 +54,7 @@ function computeSelection( } return items.filter(item => item.prevMatched !== item.matched).map(item => { return { - idx: item.idx, + idx: item.sidx as number, matched: item.matched }; }); diff --git a/windows/select.ts b/windows/select.ts index 9237483..744aa86 100644 --- a/windows/select.ts +++ b/windows/select.ts @@ -138,7 +138,7 @@ class ItemCollection { constructor(items: BaseMatchedItem[]) { this.items = items; this.assignRows(); - this.indexes = new Map(items.map(i => [i.idx, i])); + this.indexes = new Map(items.map((i, idx) => [idx, i])); } assignRows() { @@ -161,9 +161,9 @@ class ItemCollection { get checkedIndexes() { const rv: number[] = []; - this.items.forEach(function (item) { + this.items.forEach(function(item, idx) { if (item.matched && item.matched !== "unmanual") { - rv.push(item.idx); + rv.push(idx); } }); return rv;