diff --git a/lib/line_wrapper.coffee b/lib/line_wrapper.coffee index ec11e08..caa2e3c 100644 --- a/lib/line_wrapper.coffee +++ b/lib/line_wrapper.coffee @@ -141,12 +141,12 @@ class LineWrapper extends EventEmitter lh = @document.currentLineHeight(true) if @height? and @ellipsis and @document.y + lh * 2 > @maxY and @column >= @columns @ellipsis = '…' if @ellipsis is true # map default ellipsis character - buffer = buffer.trimRight() + buffer = buffer.replace(/\s+$/, '') textWidth = @wordWidth buffer + @ellipsis # remove characters from the buffer until the ellipsis fits while textWidth > @lineWidth - buffer = buffer.slice(0, -1).trimRight() + buffer = buffer.slice(0, -1).replace(/\s+$/, '') textWidth = @wordWidth buffer + @ellipsis buffer = buffer + @ellipsis diff --git a/lib/mixins/text.coffee b/lib/mixins/text.coffee index a558d99..e27b5eb 100644 --- a/lib/mixins/text.coffee +++ b/lib/mixins/text.coffee @@ -182,7 +182,7 @@ module.exports = if options.width switch align when 'right' - textWidth = @widthOfString text.trimRight(), options + textWidth = @widthOfString text.replace(/\s+$/, ''), options x += options.lineWidth - textWidth when 'center'