Skip to content

Commit 04f415c

Browse files
authored
Fix a crash that would occur with item renaming (#4178)
1 parent 60be145 commit 04f415c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Files/Views/LayoutModes/GenericFileBrowser.xaml.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
using Windows.UI.Xaml.Controls.Primitives;
2323
using Windows.UI.Xaml.Input;
2424
using Windows.UI.Xaml.Navigation;
25+
using Windows.ApplicationModel.Core;
26+
using Microsoft.Toolkit.Uwp.Helpers;
2527

2628
namespace Files.Views.LayoutModes
2729
{
@@ -292,7 +294,7 @@ private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e
292294

293295
private TextBox renamingTextBox;
294296

295-
private void AllView_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
297+
private async void AllView_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
296298
{
297299
if (ParentShellPageInstance.FilesystemViewModel.WorkingDirectory.StartsWith(AppSettings.RecycleBinPath))
298300
{
@@ -317,13 +319,17 @@ private void AllView_BeginningEdit(object sender, DataGridBeginningEditEventArgs
317319
{
318320
// We have an edit due to the first tap in the double-click mode
319321
// Let's wait to see if there is another tap (double click).
320-
tapDebounceTimer.Debounce(() =>
322+
323+
tapDebounceTimer.Debounce(async () =>
321324
{
322-
tapDebounceTimer.Stop();
325+
await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() =>
326+
{
327+
tapDebounceTimer.Stop();
323328

324-
// EditingEventArgs will be null allowing us to know this edit is not originated by tap
325-
AllView.BeginEdit();
329+
AllView.BeginEdit();
330+
});
326331
}, TimeSpan.FromMilliseconds(700), false);
332+
327333
}
328334
}
329335
else

0 commit comments

Comments
 (0)