fix truncateFilePath edge case on windows
If the filepath starts with something that is not valid utf-8, it would have returned "". And if the filepath was all non-valid utf-8, it would also return "".
This commit is contained in:
parent
b596e3b177
commit
773115fd5f
1 changed files with 8 additions and 5 deletions
|
@ -157,10 +157,13 @@ truncateFilePath n = toRawFilePath . reverse . go [] n
|
||||||
go coll cnt bs
|
go coll cnt bs
|
||||||
| cnt <= 0 = coll
|
| cnt <= 0 = coll
|
||||||
| otherwise = case S8.decode bs of
|
| otherwise = case S8.decode bs of
|
||||||
Just (c, x) | c /= S8.replacement_char ->
|
Just (c, x)
|
||||||
let x' = fromIntegral x
|
| c /= S8.replacement_char ->
|
||||||
in if cnt - x' < 0
|
let x' = fromIntegral x
|
||||||
then coll
|
in if cnt - x' < 0
|
||||||
else go (c:coll) (cnt - x') (S8.drop 1 bs)
|
then coll
|
||||||
|
else go (c:coll) (cnt - x') (S8.drop 1 bs)
|
||||||
|
| otherwise ->
|
||||||
|
go ('_':coll) (cnt - 1) (S8.drop 1 bs)
|
||||||
_ -> coll
|
_ -> coll
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue