Skip to content

Commit

Permalink
Only strip suffix in case of a match
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoaloi committed Oct 18, 2024
1 parent 8038cc8 commit 3601e0c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/els_dap_general_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1150,4 +1150,9 @@ force_delete_breakpoints(ProjectNode, Module, Breakpoints) ->

-spec strip_suffix(binary(), binary()) -> binary().
strip_suffix(Path, Suffix) ->
binary:part(Path, 0, byte_size(Path) - binary:longest_common_suffix([Path, Suffix])).
SuffixSize = byte_size(Suffix),
PathSize = byte_size(Path),
case binary:part(Path, {PathSize, -SuffixSize}) of
Suffix -> binary:part(Path, {0, PathSize - SuffixSize});
_ -> Path
end.

0 comments on commit 3601e0c

Please sign in to comment.