Skip to content

Commit

Permalink
Merge pull request #4 from erlang-ls/strip-source-path
Browse files Browse the repository at this point in the history
Add optional StripSourcePrefix option to launch config
  • Loading branch information
robertoaloi authored Oct 21, 2024
2 parents 328756f + 3601e0c commit d214eec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Escriptize Debugger
run: rebar3 escriptize
- name: Store Debugger Escript
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: els_dap
path: _build/default/bin/els_dap
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Run CT Tests
run: rebar3 ct
- name: Store CT Logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ct-logs
path: _build/test/logs
Expand All @@ -65,7 +65,7 @@ jobs:
run: rebar3 edoc
if: ${{ matrix.otp-version == '24' }}
- name: Publish Documentation
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: edoc
path: |
Expand All @@ -90,7 +90,7 @@ jobs:
- name: Run CT Tests
run: rebar3 ct
- name: Store CT Logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ct-logs
path: _build/test/logs
Expand Down
15 changes: 13 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,12 @@ force_delete_breakpoints(ProjectNode, Module, Breakpoints) ->
_ ->
ok
end.

-spec strip_suffix(binary(), binary()) -> binary().
strip_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 d214eec

Please sign in to comment.