From 48487f2a9028ee2799963d579d07413d3d1e58a2 Mon Sep 17 00:00:00 2001
From: adelikat <adelikat@tasvideos.org>
Date: Fri, 4 Dec 2015 23:18:46 -0500
Subject: [PATCH] Sort out and fix problems with Ram Search watch files showing
 up in the Ram Watch recent list

---
 BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs | 2 --
 BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs          | 2 ++
 BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs           | 3 +++
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs b/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs
index d333e787f5..cb96859d9e 100644
--- a/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs
+++ b/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs
@@ -590,7 +590,6 @@ namespace BizHawk.Client.Common
 				sw.WriteLine(sb.ToString());
 			}
 
-			Global.Config.RecentWatches.Add(CurrentFileName);
 			Changes = false;
 			return true;
 		}
@@ -734,7 +733,6 @@ namespace BizHawk.Client.Common
 
 			if (!append)
 			{
-				Global.Config.RecentWatches.Add(path);
 				Changes = false;
 			}
 			else
diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs
index 64bee85ee6..e9c54c1f8d 100644
--- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs
+++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs
@@ -850,6 +850,7 @@ namespace BizHawk.Client.EmuHawk
 
 				var watches = new WatchList(MemoryDomains, _settings.Domain, Emu.SystemId);
 				watches.Load(file.FullName, append);
+				Settings.RecentSearches.Add(watches.CurrentFileName);
 
 				var watchList = watches.Where(x => !x.IsSeparator);
 				var addresses = watchList.Select(x => x.Address).ToList();
@@ -1041,6 +1042,7 @@ namespace BizHawk.Client.EmuHawk
 					{
 						_currentFileName = watches.CurrentFileName;
 						MessageLabel.Text = Path.GetFileName(_currentFileName) + " saved";
+						Settings.RecentSearches.Add(watches.CurrentFileName);
 					}
 				}
 				else
diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs
index fa6438be1a..5c5e24b938 100644
--- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs
+++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs
@@ -141,6 +141,7 @@ namespace BizHawk.Client.EmuHawk
 					else
 					{
 						_watches.Save();
+						Global.Config.RecentWatches.Add(_watches.CurrentFileName);
 					}
 				}
 				else if (result == DialogResult.No)
@@ -693,6 +694,7 @@ namespace BizHawk.Client.EmuHawk
 			{
 				if (_watches.Save())
 				{
+					Global.Config.RecentWatches.Add(_watches.CurrentFileName);
 					UpdateStatusBar(saved: true);
 				}
 			}
@@ -1034,6 +1036,7 @@ namespace BizHawk.Client.EmuHawk
 			if (Path.GetExtension(filePaths[0]) == ".wch")
 			{
 				_watches.Load(filePaths[0], append: false);
+				Global.Config.RecentWatches.Add(_watches.CurrentFileName);
 				WatchListView.ItemCount = _watches.ItemCount;
 			}
 		}