From 151200dd34c9dbc7319edc3cb892495f43cadbdb Mon Sep 17 00:00:00 2001 From: alafr Date: Sun, 19 Nov 2017 00:29:17 +0100 Subject: [PATCH] Fix linewrapper bug - Fix #689 (the bug I created last year) - Fix #345 (the original issue) --- lib/line_wrapper.coffee | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/line_wrapper.coffee b/lib/line_wrapper.coffee index a64aa02..8f854f4 100644 --- a/lib/line_wrapper.coffee +++ b/lib/line_wrapper.coffee @@ -137,9 +137,6 @@ class LineWrapper extends EventEmitter wc++ if bk.required or w > @spaceLeft - if bk.required - @emit 'lastLine', options, this - # if the user specified a max height and an ellipsis, and is about to pass the # max height and max columns after the next line, append the ellipsis lh = @document.currentLineHeight(true) @@ -155,10 +152,14 @@ class LineWrapper extends EventEmitter buffer = buffer + @ellipsis - if bk.required and w > @spaceLeft - buffer = word - textWidth = w - wc = 1 + if bk.required + if w > @spaceLeft + emitLine() + buffer = word + textWidth = w + wc = 1 + + @emit 'lastLine', options, this emitLine()