Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed an issue where the file area would sometimes lose focus when opening a folder #13130

Merged
merged 1 commit into from
Aug 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions src/Files.App/Data/Models/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ void ClearDisplay()

return;
}
var filesAndFoldersLocal = filesAndFolders.ToList();

// CollectionChanged will cause UI update, which may cause significant performance degradation,
// so suppress CollectionChanged event here while loading items heavily.
Expand Down Expand Up @@ -643,19 +644,19 @@ void ApplyBulkInsertEntries()
}
}

for (var i = 0; i < filesAndFolders.Count; i++)
for (var i = 0; i < filesAndFoldersLocal.Count; i++)
{
if (addFilesCTS.IsCancellationRequested)
return;

if (i < FilesAndFolders.Count)
{
if (FilesAndFolders[i] != filesAndFolders[i])
if (FilesAndFolders[i] != filesAndFoldersLocal[i])
{
if (startIndex == -1)
startIndex = i;

tempList.Add(filesAndFolders[i]);
tempList.Add(filesAndFoldersLocal[i]);
}
else
{
Expand All @@ -665,16 +666,16 @@ void ApplyBulkInsertEntries()
else
{
ApplyBulkInsertEntries();
FilesAndFolders.InsertRange(i, filesAndFolders.ToList().Skip(i));
FilesAndFolders.InsertRange(i, filesAndFoldersLocal.Skip(i));

break;
}
}

ApplyBulkInsertEntries();

if (FilesAndFolders.Count > filesAndFolders.Count)
FilesAndFolders.RemoveRange(filesAndFolders.Count, FilesAndFolders.Count - filesAndFolders.Count);
if (FilesAndFolders.Count > filesAndFoldersLocal.Count)
FilesAndFolders.RemoveRange(filesAndFoldersLocal.Count, FilesAndFolders.Count - filesAndFoldersLocal.Count);

if (folderSettings.DirectoryGroupOption != GroupOption.None)
OrderGroups();
Expand Down Expand Up @@ -1638,9 +1639,9 @@ await Task.Run(async () =>

filesAndFolders.AddRange(fileList);

await dispatcherQueue.EnqueueOrInvokeAsync(CheckForSolutionFile, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low);
await OrderFilesAndFoldersAsync();
await ApplyFilesAndFoldersChangesAsync();
await dispatcherQueue.EnqueueOrInvokeAsync(CheckForSolutionFile, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low);
});

rootFolder ??= await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(path));
Expand Down Expand Up @@ -1688,16 +1689,9 @@ await Task.Run(async () =>

private void CheckForSolutionFile()
{
for (int i = 0; i < filesAndFolders.Count; i++)
{
if (FileExtensionHelpers.HasExtension(filesAndFolders[i].FileExtension, ".sln"))
{
SolutionFilePath = filesAndFolders[i].ItemPath;
return;
}
}

SolutionFilePath = null;
SolutionFilePath = filesAndFolders.ToList().AsParallel()
.Where(item => FileExtensionHelpers.HasExtension(item.FileExtension, ".sln"))
.FirstOrDefault()?.ItemPath;
}

private async Task<CloudDriveSyncStatus> CheckCloudDriveSyncStatusAsync(IStorageItem item)
Expand Down