Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional StripSourcePrefix option to launch config #4

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading