]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Removed trailing newline from clipboard text 45/3445/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 4 Nov 2019 14:12:08 +0000 (16:12 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 4 Nov 2019 14:12:08 +0000 (16:12 +0200)
When copying text to clipboard from GraphExplorer-based UI controls
(Model Browser, Selection view) using StandardCopyHandler, the produced
text no longer contains a trailing newline.

gitlab #411

Change-Id: If4141b00ed9ffc1d1dcaed53114405e8b0d20042

bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/StandardCopyHandler.java

index 9730334ccc3dcaabf67ca3ec98c33c82eb729309..3cf56fb7d79594074fb34095bb0039d8dc874708 100644 (file)
@@ -171,21 +171,23 @@ public class StandardCopyHandler extends AbstractHandler {
         Set<TreeItem> items = new THashSet<TreeItem>(selection.length);
         for (TreeItem item : selection)
             items.add(item);
+        boolean firstRow = true;
         for (TreeItem item : selection) {
+            if (!firstRow)
+                sb.append('\n');
+            firstRow = false;
             int cc = item.getParent().getColumnCount();
             int indent = indentLevel(item, items);
             for (int i = 0; i < indent; ++i)
                 sb.append('\t');
-            boolean first = true;
+            boolean firstColumn = true;
             for (int c = 0; c < cc; ++c) {
                 String ct = item.getText(c);
-                if (!first) {
+                if (!firstColumn)
                     sb.append('\t');
-                }
-                first = false;
+                firstColumn = false;
                 sb.append(ct);
             }
-            sb.append('\n');
         }
         return sb;
     }