summaryrefslogtreecommitdiff
path: root/emitter.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-08-08 16:10:57 +0200
committerAnthon van der Neut <anthon@mnt.org>2018-08-08 16:10:57 +0200
commit65c335bcf426d4954c079eda2cc5414259bea4f9 (patch)
treedce25671ea764c0ed0c7e32054ca6cecd32a91a8 /emitter.py
parent923a95aed72e446275995a5c8d83dd034099702c (diff)
downloadruamel.yaml-65c335bcf426d4954c079eda2cc5414259bea4f9.tar.gz
fix issue #216: adding spaces when empty line and shrinking key
Diffstat (limited to 'emitter.py')
-rw-r--r--emitter.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/emitter.py b/emitter.py
index 7a81372..95b3e9a 100644
--- a/emitter.py
+++ b/emitter.py
@@ -1524,7 +1524,11 @@ class Emitter(object):
try:
# get original column position
col = comment.start_mark.column
- if col < self.column + 1:
+ if comment.value and comment.value.startswith('\n'):
+ # never inject extra spaces if the comment starts with a newline
+ # and not a real comment (e.g. if you have an empty line following a key-value
+ col = self.column
+ elif col < self.column + 1:
ValueError
except ValueError:
col = self.column + 1