From e02f69ac0057ca78d2765bd7365eeaf33ebb36a8 Mon Sep 17 00:00:00 2001 From: alafr Date: Sun, 6 Nov 2016 02:28:01 +0200 Subject: [PATCH] Call emitLine() only once emitLine() was called twice in some cases --- lib/line_wrapper.coffee | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/line_wrapper.coffee b/lib/line_wrapper.coffee index cccceb9..cbd56a4 100644 --- a/lib/line_wrapper.coffee +++ b/lib/line_wrapper.coffee @@ -155,6 +155,11 @@ class LineWrapper extends EventEmitter buffer = buffer + @ellipsis + if bk.required and w > @spaceLeft + buffer = word; + textWidth = w; + wc = 1; + emitLine() # if we've reached the edge of the page, @@ -170,13 +175,6 @@ class LineWrapper extends EventEmitter # reset the space left and buffer if bk.required - # if there's a word but no space left, emit single line - if w > @spaceLeft - buffer = word - textWidth = w - wc = 1 - emitLine() - @spaceLeft = @lineWidth buffer = '' textWidth = 0