Skip to content

Commit

Permalink
Add optional StripSourcePrefix option to launch config
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoaloi committed Oct 18, 2024
1 parent 328756f commit 2bf013e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/els_dap_general_provider.erl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ handle_request({<<"initialize">>, _Params}, State) ->
Capabilities = capabilities(),
ok = els_dap_config:initialize(RootUri, Capabilities, InitOptions),
{Capabilities, State};
handle_request({<<"launch">>, #{<<"cwd">> := Cwd} = Params}, State) ->
handle_request({<<"launch">>, #{<<"cwd">> := Cwd0} = Params}, State) ->
StripSourcePrefix = maps:get(<<"stripSourcePrefix">>, Params, <<>>),
Cwd = strip_suffix(Cwd0, StripSourcePrefix),
case start_distribution(Params) of
{ok, #{
<<"projectnode">> := ProjectNode,
Expand All @@ -103,7 +105,7 @@ handle_request({<<"launch">>, #{<<"cwd">> := Cwd} = Params}, State) ->
#{
<<"kind">> => <<"integrated">>,
<<"title">> => ProjectNode,
<<"cwd">> => Cwd,
<<"cwd">> => Cwd0,
<<"args">> => Cmd
},
?LOG_INFO("Sending runinterminal request: [~p]", [ParamsR]),
Expand Down Expand Up @@ -1145,3 +1147,7 @@ force_delete_breakpoints(ProjectNode, Module, Breakpoints) ->
_ ->
ok
end.

-spec strip_suffix(binary(), binary()) -> binary().
strip_suffix(Path, Suffix) ->
binary:part(Path, 0, byte_size(Path) - binary:longest_common_suffix([Path, Suffix])).

0 comments on commit 2bf013e

Please sign in to comment.