Skip to content

Commit 7965c01

Browse files
Disable HCR button when running Java without debugging (#1167)
1 parent af96069 commit 7965c01

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
{
201201
"command": "java.debug.hotCodeReplace",
202202
"group": "navigation@100",
203-
"when": "inDebugMode && debugType == java && javaHotReload == 'manual'"
203+
"when": "inDebugMode && debugType == java && javaHotReload == 'manual' && javaHotReloadOn"
204204
}
205205
],
206206
"debug/callstack/context": [

src/hotCodeReplace.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ export function initializeHotCodeReplace(context: vscode.ExtensionContext) {
3030
vscode.commands.executeCommand("setContext", "javaHotReload", getHotReloadFlag());
3131
}
3232
});
33+
vscode.debug.onDidStartDebugSession((session) => {
34+
if (session?.configuration.noDebug && !vscode.debug.activeDebugSession) {
35+
vscode.commands.executeCommand("setContext", "javaHotReloadOn", false);
36+
}
37+
});
38+
vscode.debug.onDidChangeActiveDebugSession((session) => {
39+
vscode.commands.executeCommand("setContext", "javaHotReloadOn", session && !session.configuration.noDebug);
40+
});
3341
context.subscriptions.push(vscode.debug.onDidTerminateDebugSession((session) => {
3442
const t = session ? session.type : undefined;
3543
if (t === JAVA_LANGID) {

0 commit comments

Comments
 (0)