Counting of pending nodes does not work if null text is saved as "" 53/4253/1
authorJussi Koskela <jussi.koskela@semantum.fi>
Wed, 20 May 2020 05:15:42 +0000 (08:15 +0300)
committerJussi Koskela <jussi.koskela@semantum.fi>
Wed, 20 May 2020 05:15:42 +0000 (08:15 +0300)
gitlab #535

Change-Id: Ia4e8a0389659ce115d9cfb8febc23be0061fe3be

bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextNode.java

index 77eb789220d3118e5d8c370c2889b731450e060f..bf1bf563b32c9f9e89c2c2355902d2a5b5f1ef02 100644 (file)
@@ -403,7 +403,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
         if (hasState(STATE_EDITING))
             return;
 
-        this.text = new String(text != null ? text : "");
+        this.text = text;
         this.font = font;
         this.color = color;
         this.scale = scale;
@@ -470,8 +470,8 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
         // no value => value
         if(this.text == null && text != null) NodeUtil.decreasePending(this);
 
-        this.text = text != null ? text : "";
-        caret = Math.min(caret, this.text.length());
+        this.text = text;
+        caret = text != null ? Math.min(caret, text.length()) : 0;
         selectionTail = caret;
 
         resetCaches();