From 6c7809ec7693432c096ebcbaa38aef9a92a138d6 Mon Sep 17 00:00:00 2001
From: Sojourner Truth <jon.w.wilkes@gmail.com>
Date: Tue, 19 Jul 2016 22:04:14 -0400
Subject: [PATCH] fix awful regression where deleting the end of a comment, a
 message, or the trailing arguments of an object didn't actually change the
 state of the object in Pd.

---
 pd/src/g_editor.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index 51440e073..77b649787 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -7470,7 +7470,12 @@ static void canvas_buftotext(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
                as x_bufsize. Pd will handle deallocation of those members
                automatically, so we don't need to free the "buf" here. */
             rtext_settext(rtext, buf, length);
-            if (binbuf_match(((t_text *)y)->te_binbuf, b, 1))
+            /* Here we are abusing binbuf_match-- it was written only to see
+               if a subset of a binbuf matches a larger one. So we have to
+               also compare the size of both binbufs to tell if it is an
+               exact match. */
+            if (binbuf_match(((t_text *)y)->te_binbuf, b, 1) &&
+                binbuf_getnatom(((t_text *)y)->te_binbuf) == binbuf_getnatom(b))
                 x->gl_editor->e_textdirty = 0;
             else
                 x->gl_editor->e_textdirty = 1;
-- 
GitLab