Skip to content

Commit 4724da0

Browse files
committed
Take into account Context initial state #13
1 parent d2cdb6c commit 4724da0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "macos-multi-select",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Given a list of ids, and an action, return a list of selected items with the same behaviour of macOS finder list view selection.",
55
"main": "dist/index.js",
66
"repository": "[email protected]:codingedgar/macos-multi-select.git",

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { findAdjacentToPivotInSortedArray, findNextPivot } from "./arrayUtils";
44
export type Context = {
55
list: string[],
66
selected: string[],
7-
adjacentPivotstring,
7+
adjacentPivotstring | undefined,
88
}
99

1010
type Command =
@@ -84,7 +84,8 @@ export function multiselect(context: Context, command: Command): Context {
8484
}
8585
} else if (
8686
command.type === "SELECT ADJACENT" &&
87-
listIncludesAndIsNotEmpty(context.list, command.id)
87+
listIncludesAndIsNotEmpty(context.list, command.id) &&
88+
context.adjacentPivot !== undefined
8889
) {
8990

9091
const pivotIndex = context.list.indexOf(context.adjacentPivot);

0 commit comments

Comments
 (0)