Fix infinite loop in truncation algorithm
This algorithm doesn't handle the case when a path, fully-ellipsised, is still longer than the specified maxWidth. For example, for a path with 21 segments, the string the util would build is …/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…/…, which is 41 characters long, so the `while` condition is never false, leading to the infinite loop. This adds a condition to handle that case, returning a truncated string that never exceeds the maxWidth, no matter how deep the path is.
Showing
Please register or sign in to comment