Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit ad02d8f

Browse files
fix the inconsistent uri issue for set breakpoint request (microsoft#84)
* fix the inconsistent uri issue for set breakpoint request Signed-off-by: Jinbo Wang <jinbwan@microsoft.com> * add vscode bug number Signed-off-by: Jinbo Wang <jinbwan@microsoft.com> * fix review comments Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
1 parent 6158bf2 commit ad02d8f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/AdapterUtils.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
package com.microsoft.java.debug.core.adapter;
1313

14+
import java.io.UnsupportedEncodingException;
1415
import java.net.URI;
1516
import java.net.URISyntaxException;
17+
import java.net.URLDecoder;
1618
import java.nio.charset.StandardCharsets;
1719
import java.nio.file.FileSystemNotFoundException;
1820
import java.nio.file.Files;
@@ -220,4 +222,18 @@ public static String getSHA256HexDigest(String content) {
220222
}
221223
return buf.toString();
222224
}
225+
226+
/**
227+
* Decode the uri string.
228+
* @param uri
229+
* the uri string
230+
* @return the decoded uri
231+
*/
232+
public static String decodeURIComponent(String uri) {
233+
try {
234+
return URLDecoder.decode(uri, StandardCharsets.UTF_8.name());
235+
} catch (UnsupportedEncodingException e) {
236+
return uri;
237+
}
238+
}
223239
}

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/SetBreakpointsRequestHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ public void handle(Command command, Arguments arguments, Response response, IDeb
8181
try {
8282
List<Types.Breakpoint> res = new ArrayList<>();
8383
IBreakpoint[] toAdds = this.convertClientBreakpointsToDebugger(sourcePath, bpArguments.breakpoints, context);
84-
IBreakpoint[] added = manager.setBreakpoints(sourcePath, toAdds, bpArguments.sourceModified);
84+
// See the VSCode bug https://github.com/Microsoft/vscode/issues/36471.
85+
// The source uri sometimes is encoded by VSCode, the debugger will decode it to keep the uri consistent.
86+
IBreakpoint[] added = manager.setBreakpoints(AdapterUtils.decodeURIComponent(sourcePath), toAdds, bpArguments.sourceModified);
8587
for (int i = 0; i < bpArguments.breakpoints.length; i++) {
8688
// For newly added breakpoint, should install it to debuggee first.
8789
if (toAdds[i] == added[i] && added[i].className() != null) {

0 commit comments

Comments
 (0)