Skip to content

Commit

Permalink
Proper fix for data breakpoint option not appearing on variable conte…
Browse files Browse the repository at this point in the history
…xt menu
  • Loading branch information
gjsjohnmurray committed Oct 16, 2023
1 parent 3a498fa commit 5b7a4ab
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/debug/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
supportsDataBreakpoints: true,
};

// Reset this at start of each session because our logic around whether to offer data breakpoints depends on context ids of Private and Public root folders being 1 or 2
this._variableIdCounter = 1;

try {
const file = currentFile();
this._workspace = file?.workspaceFolder;
Expand Down Expand Up @@ -487,8 +484,12 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
response: DebugProtocol.DataBreakpointInfoResponse,
args: DebugProtocol.DataBreakpointInfoArguments
): void {
if (args.variablesReference !== undefined && (args.variablesReference === 1 || args.variablesReference === 2)) {
// This is a private or public local variable
if (
args.variablesReference !== undefined &&
[0, 1].includes(this._contexts.get(args.variablesReference).id) &&
!args.name.includes("(")
) {
// This is an unsubscripted private or public local variable
response.body = {
dataId: args.name,
description: args.name,
Expand All @@ -497,7 +498,8 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
// This is an object property or array element, or args.variablesReference is undefined
response.body = {
dataId: null,
description: "Can only set a watchpoint on a local variable",
// This message isn't surfaced in VS Code, which simply doesn't offer the context menu option when dataId is null
description: "Can only set a watchpoint on an unsubscripted local variable",
};
}

Expand Down

0 comments on commit 5b7a4ab

Please sign in to comment.