From 14dd27ebd52de5cbf82519ecc6d081c04b86ecb2 Mon Sep 17 00:00:00 2001 From: Julius K Date: Thu, 2 Mar 2023 16:04:31 +0100 Subject: [PATCH] This fixes #105 --- Fastedit/Tab/TabPageHelper.cs | 6 ++++-- Fastedit/Views/TabWindowPage.xaml.cs | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Fastedit/Tab/TabPageHelper.cs b/Fastedit/Tab/TabPageHelper.cs index 089493e..99b6718 100644 --- a/Fastedit/Tab/TabPageHelper.cs +++ b/Fastedit/Tab/TabPageHelper.cs @@ -257,8 +257,10 @@ public static async Task CloseTab(TabView tabView, object tabItem) } private static async Task 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); diff --git a/Fastedit/Views/TabWindowPage.xaml.cs b/Fastedit/Views/TabWindowPage.xaml.cs index e408624..6bd7a70 100644 --- a/Fastedit/Views/TabWindowPage.xaml.cs +++ b/Fastedit/Views/TabWindowPage.xaml.cs @@ -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; @@ -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); }