Repository: amzn/ion-java (java)

Issue:
When pretty-printing, add a space immediately after fieldname:
Currently, pretty-printing {total:dollars::45} produces:
```
{
  total:dollars::45
}
```
This becomes more readable if a space is added after total:, as in:
```
{
  total: dollars::45
}
```

Pull request description:
Adds a space after a fieldname's colon when pretty-printing
Resolves #288 

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.


Patch:
diff --git a/src/com/amazon/ion/impl/IonWriterSystemText.java b/src/com/amazon/ion/impl/IonWriterSystemText.java
index 0e78e95c..f577c26e 100644
--- a/src/com/amazon/ion/impl/IonWriterSystemText.java
+++ b/src/com/amazon/ion/impl/IonWriterSystemText.java
@@ -366,6 +366,9 @@ class IonWriterSystemText
             SymbolToken sym = assumeFieldNameSymbol();
             writeFieldNameToken(sym);
             _output.appendAscii(':');
+            if (_options.isPrettyPrintOn()) {
+                _output.appendAscii(' ');
+            }
             clearFieldName();
             followingLongString = false;
         }


Test patch:
diff --git a/test/com/amazon/ion/impl/IonMarkupWriterTest.java b/test/com/amazon/ion/impl/IonMarkupWriterTest.java
index b84d7a7d..f7067d05 100644
--- a/test/com/amazon/ion/impl/IonMarkupWriterTest.java
+++ b/test/com/amazon/ion/impl/IonMarkupWriterTest.java
@@ -54,7 +54,7 @@ public class IonMarkupWriterTest extends IonTestCase {
             "%n<beforeAnnotations STRUCT><beforeEachAnnotation STRUCT>abcd" +
             "<afterEachAnnotation STRUCT>::<afterAnnotations STRUCT><beforeData" +
             " STRUCT>{<afterStepIn STRUCT>%n  <beforeFieldName SEXP>hello" +
-            "<afterFieldName SEXP>:<beforeData SEXP>(<afterStepIn SEXP>%n    " +
+            "<afterFieldName SEXP>: <beforeData SEXP>(<afterStepIn SEXP>%n    " +
             "<beforeData SYMBOL>sexp<afterData SYMBOL><beforeSeparator SEXP>" +
             "%n    <afterSeparator SEXP><beforeData INT>1<afterData INT>" +
             "<beforeSeparator SEXP>%n    <afterSeparator SEXP><beforeData INT>2" +
@@ -62,12 +62,12 @@ public class IonMarkupWriterTest extends IonTestCase {
             "<beforeData STRING>\"str\"<afterData STRING><beforeStepOut SEXP>%n  " +
             ")<afterData SEXP><beforeSeparator STRUCT>,%n  " +
             "<afterSeparator STRUCT><beforeFieldName LIST>list<afterFieldName " +
-            "LIST>:<beforeData LIST>[<afterStepIn LIST>%n    <beforeData " +
+            "LIST>: <beforeData LIST>[<afterStepIn LIST>%n    <beforeData " +
             "DECIMAL>3.2<afterData DECIMAL><beforeSeparator LIST>,%n    " +
             "<afterSeparator LIST><beforeData FLOAT>3.2e0<afterData FLOAT>" +
             "<beforeStepOut LIST>%n  ]<afterData LIST><beforeSeparator STRUCT>" +
             ",%n  <afterSeparator STRUCT><beforeFieldName BLOB>blob" +
-            "<afterFieldName BLOB>:<beforeAnnotations BLOB>" +
+            "<afterFieldName BLOB>: <beforeAnnotations BLOB>" +
             "<beforeEachAnnotation BLOB>annot<afterEachAnnotation BLOB>::" +
             "<afterAnnotations BLOB><beforeData BLOB>" +
             "{{ T25lIEJpZyBGYXQgVGVzdCBCbG9iIEZvciBZb3VyIFBsZWFzdXJl }}" +
diff --git a/test/com/amazon/ion/impl/TextWriterTest.java b/test/com/amazon/ion/impl/TextWriterTest.java
index ba57d634..8c8b527b 100644
--- a/test/com/amazon/ion/impl/TextWriterTest.java
+++ b/test/com/amazon/ion/impl/TextWriterTest.java
@@ -287,14 +287,14 @@ public class TextWriterTest
                 "%n" +
                 "'''looong'''%n" +
                 "{%n" +
-                        "  a:'''looong''',%n" +
-                "  b:\"hello\",%n" +
-                "  c:'''hello\n" +
+                "  a: '''looong''',%n" +
+                "  b: \"hello\",%n" +
+                "  c: '''hello\n" +
                         "nurse''',%n" +
-                        "  d:'''what\\'s\n" +
+                "  d: '''what\\'s\n" +
                         "up\n" +
                         "doc'''%n" +
-                        "}"
+                "}"
             ),
             dg
         );