From 79eeb03a5002dfd917f4ab390c0d042e41280b59 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 23 Jun 2016 23:11:53 -0400 Subject: [PATCH] Bug1382 again: Don't dirty undo stack exporting with no tag change --- src/Tags.cpp | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/Tags.cpp b/src/Tags.cpp index 5849ad72f..842dd2251 100644 --- a/src/Tags.cpp +++ b/src/Tags.cpp @@ -460,17 +460,35 @@ void Tags::SetTag(const wxString & name, const wxString & value) // Look it up TagMap::iterator iter = mXref.find(key); - // Didn't find the tag - if (iter == mXref.end()) { - - // Add a NEW tag - mXref[key] = name; - mMap[name] = value; - return; + if (value.IsEmpty()) { + // Erase the tag + if (iter == mXref.end()) + // nothing to do + ; + else { + mMap.erase(iter->second); + mXref.erase(iter); + } } + else { + if (iter == mXref.end()) { + // Didn't find the tag - // Update the value - mMap[iter->second] = value; + // Add a NEW tag + mXref[key] = name; + mMap[name] = value; + } + else if (!iter->second.IsSameAs(name)) { + // Watch out for case differences! + mMap[name] = value; + mMap.erase(iter->second); + iter->second = name; + } + else { + // Update the value + mMap[iter->second] = value; + } + } } void Tags::SetTag(const wxString & name, const int & value)