From 1768c91474d8e58a484517cd9ab84cf80164bd73 Mon Sep 17 00:00:00 2001 From: Junglei Kim <67102441+imjlk@users.noreply.github.com> Date: Mon, 9 Oct 2023 10:04:48 +0900 Subject: [PATCH] fix: support reversed multiple selections --- components/object-explorer/explorer.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/object-explorer/explorer.tsx b/components/object-explorer/explorer.tsx index 6eadf4a..9c8848c 100644 --- a/components/object-explorer/explorer.tsx +++ b/components/object-explorer/explorer.tsx @@ -307,7 +307,9 @@ export const ObjectExplorer = ({ initialObjects, initialCursor }: Props): JSX.El if (lastSelectedIdx === -1) { addSelectedObject(object.path, objInfo); } else { - for (let i = lastSelectedIdx; i <= objInfo.idx; i++) { + const start = Math.min(lastSelectedIdx, objInfo.idx); + const end = Math.max(lastSelectedIdx, objInfo.idx); + for (let i = start; i <= end; i++) { const nextObj = rows[i]; if (nextObj) addSelectedObject(nextObj.original.path, { idx: i }); }