Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/line_wrapper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,16 @@ class LineWrapper extends EventEmitter
textWidth = @wordWidth buffer + @ellipsis

# remove characters from the buffer until the ellipsis fits
while textWidth > @lineWidth
# to avoid inifinite loop need to stop while-loop if buffer is empty string
while buffer and textWidth > @lineWidth
buffer = buffer.slice(0, -1).replace(/\s+$/, '')
textWidth = @wordWidth buffer + @ellipsis

buffer = buffer + @ellipsis

# need to add ellipsis only if there is enough space for it
if textWidth <= @lineWidth
buffer = buffer + @ellipsis

textWidth = @wordWidth buffer

if bk.required
if w > @spaceLeft
emitLine()
Expand Down