mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Fix linewrapper ellipsis inifinite loop (#779)
This commit is contained in:
parent
f91bdd61c1
commit
56c7debb89
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user