Skip to content

Commit 3ad9d3a

Browse files
Merge pull request #72 from dave-se/add_path_separator
feat: add pathSeparator option to control debugger path normalization
2 parents a48187f + 9e7c9d0 commit 3ad9d3a

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

readme.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,20 @@ A CFML debug configuration looks like:
134134
"idePrefix": "${workspaceFolder}",
135135
"serverPrefix": "/app"
136136
}
137-
]
137+
],
138+
// optional; controls how paths returned from the debugger are normalized in the client.
139+
// options:
140+
// "none" - (default) no normalization; use paths exactly as returned from the debugger
141+
// "auto" - use the platform default (e.g., "/" on macOS/Linux, "\" on Windows)
142+
// "posix" - always use forward slashes ("/")
143+
// "windows" - always use backslashes ("\")
144+
"pathSeparator": "auto"
138145
}
139146
```
140147
`hostName`/`port` should match the `debugHost`/`debugPort` of the Java agent's configuration. (There are exceptions; e.g., on remote hosts where DNS and/or port forwarding are in play.)
141148

149+
Use the `pathSeparator` option to control how file paths returned from the server are interpreted on your client machine. This is useful when debugging across different operating systems or dealing with platform-specific path formats.
150+
142151
#### Mapping Paths with `pathTransforms`
143152

144153

vscode-client/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vscode-client/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@
125125
"serverPrefix": "/container-root/app"
126126
}
127127
]
128+
},
129+
"pathSeparator": {
130+
"type": "string",
131+
"enum": ["none", "auto", "posix", "windows"],
132+
"default": "auto",
133+
"description": "How paths returned from the debugger should be normalized (none, auto, posix, or windows)."
128134
}
129135
}
130136
}
@@ -141,6 +147,7 @@
141147
"serverPrefix": "/app"
142148
}
143149
],
150+
"pathSeparator": "auto",
144151
"port": 8000
145152
}
146153
],
@@ -159,6 +166,7 @@
159166
"serverPrefix": "/app"
160167
}
161168
],
169+
"pathSeparator": "auto",
162170
"port": 8000
163171
}
164172
}

vscode-client/src/extension.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ export function activate(context: vscode.ExtensionContext) {
6464
}
6565
}
6666

67+
const normalizePathFromSession = (session: vscode.DebugSession, path: string): string => {
68+
const pathSeparator = session.configuration?.pathSeparator ?? "auto";
69+
if (pathSeparator === "none") return path;
70+
71+
const platformDefault = process.platform === "win32" ? "\\" : "/";
72+
const normalizedSeparator = pathSeparator === "posix"
73+
? "/"
74+
: pathSeparator === "windows"
75+
? "\\"
76+
: platformDefault;
77+
return path.replace(/[\\/]/g, normalizedSeparator);
78+
};
79+
6780
context.subscriptions.push(
6881
vscode.commands.registerCommand("luceedebug.dump", async (args?: Partial<DebugPaneContextMenuArgs>) => {
6982
if (args?.variable === undefined || args.variable.variablesReference === 0) {
@@ -219,6 +232,13 @@ export function activate(context: vscode.ExtensionContext) {
219232
outputChannel.append(JSON.stringify(message, null, 4) + "\n");
220233
},
221234
onDidSendMessage(message: any) : void {
235+
if (message.command === "stackTrace" || (message.type === "response" && message.body?.stackFrames)) {
236+
for (const frame of message.body.stackFrames) {
237+
if (frame.source?.path) {
238+
frame.source.path = normalizePathFromSession(session, frame.source.path);
239+
}
240+
}
241+
}
222242
outputChannel.append(JSON.stringify(message, null, 4) + "\n");
223243
}
224244
}

0 commit comments

Comments
 (0)