diff options
author | Charles Oliver Nutter <headius@headius.com> | 2017-02-24 09:12:48 -0600 |
---|---|---|
committer | Charles Oliver Nutter <headius@headius.com> | 2017-02-24 09:12:48 -0600 |
commit | 1d404f227253545710546fda8b708848c24a9d09 (patch) | |
tree | 3e64ea232eb4d9af3eb5cfc51e903a5bfbe6a5bf | |
parent | 9279f6736cf1f8a5b92d804862d6bd4ec39b4ae8 (diff) | |
download | psych-1d404f227253545710546fda8b708848c24a9d09.zip |
Treat negative or zero-width as max possible width.
Not sure why snakeyaml doesn't follow libyaml here. I'll follow
up with them.
-rw-r--r-- | ext/java/PsychEmitter.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/java/PsychEmitter.java b/ext/java/PsychEmitter.java index d9f3231..35eff96 100644 --- a/ext/java/PsychEmitter.java +++ b/ext/java/PsychEmitter.java @@ -101,7 +101,7 @@ public class PsychEmitter extends RubyObject { options.setCanonical(canonical.isTrue()); options.setIndent((int)level.convertToInteger().getLongValue()); - options.setWidth((int)width.convertToInteger().getLongValue()); + line_width_set(context, width); this.io = io; @@ -296,7 +296,9 @@ public class PsychEmitter extends RubyObject { @JRubyMethod(name = "line_width=") public IRubyObject line_width_set(ThreadContext context, IRubyObject width) { - options.setWidth((int)width.convertToInteger().getLongValue()); + int newWidth = (int)width.convertToInteger().getLongValue(); + if (newWidth <= 0) newWidth = Integer.MAX_VALUE; + options.setWidth(newWidth); return width; } |