From 6c435d1e7d21f9af18ff05e9b15da7ea141b83c3 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Mon, 31 Aug 2015 23:36:40 -0400
Subject: [PATCH] trim leading/trailing spaces on GUI side for obj/msg box text

---
 pd/nw/pdgui.js | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 9454e92cf..6ee941de0 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -2210,6 +2210,8 @@ function gui_gobj_erase(cid, tag) {
 function gui_text_set (cid, tag, text) {
     var svg_text = get_item(cid, tag + 'text');
     if (svg_text !== null) {
+        // trim leading/trailing whitespace
+        text = text.trim();
         svg_text.textContent = '';
         text_to_tspans(cid, svg_text, text);
     } else {
@@ -3756,6 +3758,8 @@ function gui_textarea(cid, tag, type, x, y, max_char_width, text, font_size, sta
             max_char_width === 0 ? '60ch' : max_char_width + 'ch');
         p.style.setProperty('min-width',
             max_char_width === 0 ? '3ch' : max_char_width + 'ch');
+        // remove leading/trailing whitespace
+        text = text.trim();
         p.textContent = text;
         patchwin[cid].window.document.body.appendChild(p);
         p.focus();
-- 
GitLab