Skip to content

Commit

Permalink
Merge pull request #108 from FrozenAssassine/fixfor#105
Browse files Browse the repository at this point in the history
Fix: add tabs only to recylce bin when they were modified
  • Loading branch information
FrozenAssassine authored May 10, 2023
2 parents a3280dd + 14dd27e commit d6d5488
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Fastedit/Tab/TabPageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,10 @@ public static async Task<bool> CloseTab(TabView tabView, object tabItem)
}
private static async Task<bool> RemoveTab(TabView tabView, TabPageItem tab)
{
if (!await RecycleBinDialog.MoveFileToRecycleBin(tab))
return false;
//only add the file to the recylcbin when it has some content and was modified
if (tab.DatabaseItem.IsModified && tab.textbox.CharacterCount > 0)
if (!await RecycleBinDialog.MoveFileToRecycleBin(tab))
return false;

tab.textbox.Unload();
tabView.TabItems.Remove(tab);
Expand Down
5 changes: 5 additions & 0 deletions Fastedit/Views/TabWindowPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Fastedit.Storage;
using Fastedit.Tab;
using System;
using System.Linq;
using Windows.UI.WindowManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
Expand Down Expand Up @@ -65,6 +66,10 @@ private async void Open_Click(object sender, RoutedEventArgs e)
if (tab.DatabaseItem.IsModified && !await AskSaveDialog.Show(tab, this.XamlRoot))
return;

//only add the file to the recylcbin when it has some content and was modified
if (tab.DatabaseItem.IsModified && tab.textbox.CharacterCount > 0)
await RecycleBinDialog.MoveFileToRecycleBin(tab);

await OpenFileHelper.OpenFileForTab(tab);
}

Expand Down

0 comments on commit d6d5488

Please sign in to comment.