From 35dad1156e914db9c956379b3466c6b602ca47b2 Mon Sep 17 00:00:00 2001 From: crschnick Date: Tue, 4 Apr 2023 17:11:09 +0000 Subject: [PATCH] Fix file browser shift selection --- app/src/main/java/io/xpipe/app/browser/FileListCompEntry.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/xpipe/app/browser/FileListCompEntry.java b/app/src/main/java/io/xpipe/app/browser/FileListCompEntry.java index bb427222f..728dce1fb 100644 --- a/app/src/main/java/io/xpipe/app/browser/FileListCompEntry.java +++ b/app/src/main/java/io/xpipe/app/browser/FileListCompEntry.java @@ -52,8 +52,10 @@ public class FileListCompEntry { if (t.getButton() == MouseButton.PRIMARY && t.isShiftDown()) { var tv = ((TableView) row.getParent().getParent().getParent().getParent()); var all = tv.getItems(); - var start = tv.getSelectionModel().getSelectedItems().stream().mapToInt(entry -> all.indexOf(entry)).min().orElse(1); + var min = tv.getSelectionModel().getSelectedItems().stream().mapToInt(entry -> all.indexOf(entry)).min().orElse(1); + var max = tv.getSelectionModel().getSelectedItems().stream().mapToInt(entry -> all.indexOf(entry)).max().orElse(all.size() - 1); var end = all.indexOf(item); + var start = end > min ? min : max; model.getSelected().setAll(all.subList(Math.min(start, end), Math.max(start, end) + 1)); t.consume(); return;