Repository: files-community/Files
File: src/Files.App/Views/Layouts/BaseLayoutPage.cs (C#)

Code before:
						ItemManipulationModel.ScrollIntoView(jumpedToItem);
						ItemManipulationModel.FocusSelectedItems();
					}

					// Restart the timer
					jumpTimer.Start();
				}

				jumpString = value;
			}
		}

		private bool isSelectedItemsSorted = false;
		private List<ListedItem>? selectedItems = [];
		public List<ListedItem>? SelectedItems
		{
			get {
				if (!isSelectedItemsSorted)
				{
					var orderedItems = SortingHelper.OrderFileList(selectedItems, FolderSettings.DirectorySortOption, FolderSettings.DirectorySortDirection, FolderSettings.SortDirectoriesAlongsideFiles, FolderSettings.SortFilesFirst).ToList();
					selectedItems = orderedItems;
					isSelectedItemsSorted = true;
				}
				if (clickedItem is null || !selectedItems!.Contains(clickedItem))
					return selectedItems;
				return selectedItems.SkipWhile(x => x != clickedItem).Concat(selectedItems.TakeWhile(x => x != clickedItem)).ToList();
			}
			internal set
			{
				clickedItem = null;
				if (value != selectedItems)
				{
					isSelectedItemsSorted = false;
					selectedItems = value;

					if (selectedItems?.Count == 0 || selectedItems?[0] is null)
					{
						IsItemSelected = false;
						SelectedItem = null;
						SelectedItemsPropertiesViewModel.IsItemSelected = false;

						ResetRenameDoubleClick();
						UpdateSelectionSize();
					}
					else if (selectedItems is not null)
					{
						IsItemSelected = true;
						SelectedItem = selectedItems.First();
						SelectedItemsPropertiesViewModel.IsItemSelected = true;

						UpdateSelectionSize();

Review comment (suggestion):
```suggestion
				if (clickedItem is null || !selectedItems!.Contains(clickedItem))
					return selectedItems;
				else
					return selectedItems.SkipWhile(x => x != clickedItem).Concat(selectedItems.TakeWhile(x => x != clickedItem)).ToList();
```

Code after:
						ItemManipulationModel.FocusSelectedItems();
					}

					// Restart the timer
					jumpTimer.Start();
				}

				jumpString = value;
			}
		}

		private bool isSelectedItemsSorted = false;
		private List<ListedItem>? selectedItems = [];
		public List<ListedItem>? SelectedItems
		{
			get
			{
				if (!isSelectedItemsSorted)
				{
					var orderedItems = SortingHelper.OrderFileList(selectedItems, FolderSettings.DirectorySortOption, FolderSettings.DirectorySortDirection, FolderSettings.SortDirectoriesAlongsideFiles, FolderSettings.SortFilesFirst).ToList();
					selectedItems = orderedItems;
					isSelectedItemsSorted = true;
				}

				return SelectedItem is null || !selectedItems!.Contains(SelectedItem)
					? selectedItems
					: selectedItems
						.SkipWhile(x => x != SelectedItem)
						.Concat(selectedItems.TakeWhile(x => x != SelectedItem))
						.ToList();
			}
			internal set
			{
				if (value != selectedItems)
				{
					isSelectedItemsSorted = false;
					selectedItems = value;

					if (selectedItems?.Count == 0 || selectedItems?[0] is null)
					{
						IsItemSelected = false;
						SelectedItem = null;
						SelectedItemsPropertiesViewModel.IsItemSelected = false;

						ResetRenameDoubleClick();
						UpdateSelectionSize();
					}
					else if (selectedItems is not null)
					{
						IsItemSelected = true;
						SelectedItem = selectedItems.First();