Skip to content

Commit

Permalink
Merge pull request #2939 from zhongwencool/main
Browse files Browse the repository at this point in the history
fix: crash on rebar_compiler_format:colorize/2
  • Loading branch information
ferd authored Feb 26, 2025
2 parents 9311637 + 274cf7a commit 942875e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/rebar/src/rebar_compiler_format.erl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ compiler_error_format(Opts) ->
colorize(Str, Col) ->
Pre = string:slice(Str, 0, max(0,Col-1)),
At = string:slice(Str, max(0,Col-1)),
[Bad | Tail] = [B || B <- re:split(At, "([^[A-Za-z0-9_#\"]+)", []),
B =/= <<>>],
cf:format("~ts~!R~ts~!!~ts", [Pre,Bad,Tail]).
case [B || B <- re:split(At, "([^[A-Za-z0-9_#\"]+)", []),
B =/= <<>>] of
[Bad |Tail] ->
cf:format("~ts~!R~ts~!!~ts", [Pre,Bad,Tail]);
[] ->
cf:format("~ts~n", [Str])
end.

0 comments on commit 942875e

Please sign in to comment.