summaryrefslogtreecommitdiff
path: root/emitter.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-12-28 17:14:28 +0100
committerAnthon van der Neut <anthon@mnt.org>2018-12-28 17:14:28 +0100
commit3ac28c509c0759a881ebfd06d300507e8db2c9d2 (patch)
tree1e12c26ddc454f101496c91729b60deeaa5c47a9 /emitter.py
parent96cf5fdbbfec1902fcaeeb3ba6c75ccf92f1f2f7 (diff)
downloadruamel.yaml-3ac28c509c0759a881ebfd06d300507e8db2c9d2.tar.gz
preserve anchors on scalars, on tagged objects0.15.82
fixes issue #63 fixes issue #266 *When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))*
Diffstat (limited to 'emitter.py')
-rw-r--r--emitter.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/emitter.py b/emitter.py
index 7829219..d4c51f9 100644
--- a/emitter.py
+++ b/emitter.py
@@ -402,8 +402,12 @@ class Emitter(object):
if isinstance(self.event, AliasEvent):
self.expect_alias()
elif isinstance(self.event, (ScalarEvent, CollectionStartEvent)):
- if self.process_anchor(u'&') and isinstance(self.event, ScalarEvent):
- self.no_newline = True
+ if (
+ self.process_anchor(u'&')
+ and isinstance(self.event, ScalarEvent)
+ and self.sequence_context
+ ):
+ self.sequence_context = False
self.process_tag()
if isinstance(self.event, ScalarEvent):
# nprint('@', self.indention, self.no_newline, self.column)
@@ -848,6 +852,7 @@ class Emitter(object):
# if self.analysis.multiline and split \
# and (not self.style or self.style in '\'\"'):
# self.write_indent()
+ # nprint('xx', self.sequence_context, self.flow_level)
if self.sequence_context and not self.flow_level:
self.write_indent()
if self.style == '"':