summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2022-05-16 09:39:22 +0200
committerAnthon van der Neut <anthon@mnt.org>2022-05-16 09:39:22 +0200
commitacfa21bfb90cf3d6ef73d3eed0a8294c33cde2c4 (patch)
tree8f42e17582675081edabbb326754615fb1934ccf
parent5de4975b5a7fd995036f47584a9c8a8acd12409b (diff)
downloadruamel.yaml-cleanup_0_18.tar.gz
put words longer than linelenght on a line of their owncleanup_0_18
-rw-r--r--README.rst3
-rw-r--r--constructor.py3
-rw-r--r--emitter.py3
3 files changed, 8 insertions, 1 deletions
diff --git a/README.rst b/README.rst
index 42162ec..179bba3 100644
--- a/README.rst
+++ b/README.rst
@@ -80,6 +80,9 @@ NEXT:
are created if you have a sequence resp. mapping as the key in a mapping)
- fix loading of `!!float 42` (reported by Eric on
`Stack overflow <https://stackoverflow.com/a/71555107/1307905>`_)
+ - plain scalars: put single words longer than width on a line of their own, instead
+ of after the previous line (issue 427, reported by `Antoine Cotten
+ <https://sourceforge.net/u/antoineco/profile/>`_)
0.17.21 (2022-02-12):
- fix bug in calling `.compose()` method with `pathlib.Path` instance.
diff --git a/constructor.py b/constructor.py
index 99d3295..4fe1cba 100644
--- a/constructor.py
+++ b/constructor.py
@@ -1162,7 +1162,8 @@ class RoundTripConstructor(SafeConstructor):
anchor=node.anchor,
)
width = len(value_so)
- prec = value_so.find('.') # you can't use index, !!float 42 would be a float without a dot
+ # you can't use index, !!float 42 would be a float without a dot
+ prec = value_so.find('.')
lead0 = leading_zeros(value_so)
return ScalarFloat(
sign * float(value_s),
diff --git a/emitter.py b/emitter.py
index 08b6bb0..d3576e0 100644
--- a/emitter.py
+++ b/emitter.py
@@ -1618,6 +1618,9 @@ class Emitter:
else:
if ch is None or ch in ' \n\x85\u2028\u2029':
data = text[start:end]
+ if len(data) > self.best_width and self.column > self.indent:
+ # words longer than line length get a line of their own
+ self.write_indent()
self.column += len(data)
if self.encoding:
data = data.encode(self.encoding) # type: ignore