From 29bf1fe22483ec67a7cc9697baf0d856f62b430f Mon Sep 17 00:00:00 2001
From: Paul <baconpaul@users.noreply.github.com>
Date: Fri, 12 Jan 2024 07:51:16 -0500
Subject: [PATCH] Undo on TypeIn and Mod TypeIn (#7435)

Amazingly, we didn't push an undo on param set via typein
or param mod set via typein. How did we not find this for so
long!

Closes #7433
---
 src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp b/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp
index df0cb5b0505..f0b705a6ffe 100644
--- a/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp
+++ b/src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp
@@ -4100,8 +4100,16 @@ bool SurgeGUIEditor::setParameterFromString(Parameter *p, const std::string &s,
 {
     auto v = p->get_value_f01();
 
-    if (p && p->set_value_from_string(s, errMsg))
+    if (p)
     {
+        undoManager()->pushParameterChange(p->id, p, p->val);
+        auto res = p->set_value_from_string(s, errMsg);
+
+        if (!res)
+        {
+            return false;
+        }
+
         if (v != p->get_value_f01())
             synth->storage.getPatch().isDirty = true;
         repushAutomationFor(p);
@@ -4127,6 +4135,10 @@ bool SurgeGUIEditor::setParameterModulationFromString(Parameter *p, modsources m
     }
     else
     {
+        undoManager()->pushModulationChange(
+            p->id, p, ms, modsourceScene, modidx,
+            synth->getModDepth01(p->id, ms, modsourceScene, modidx),
+            synth->isModulationMuted(p->id, ms, modsourceScene, modidx));
         synth->setModDepth01(p->id, ms, modsourceScene, modidx, mv);
         synth->refresh_editor = true;
         synth->storage.getPatch().isDirty = true;