Skip to content

Commit

Permalink
fix: support object property shorthand in logpoints
Browse files Browse the repository at this point in the history
Fixes #1788
  • Loading branch information
connor4312 committed Jan 31, 2024
1 parent 3b01ac9 commit 1c683f5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he

## Nightly (only)

- fix: support object property shorthand in logpoints ([#1788](https://github.com/microsoft/vscode-js-debug/issues/1788))
- fix: pages not loading in browser after attach browser disconnect ([#1795](https://github.com/microsoft/vscode-js-debug/issues/1795))
- fix: skipFiles not matching/negating with special chars ([vscode#203408](https://github.com/microsoft/vscode/issues/203408))

Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/adapter/breakpoints/conditions/logPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ export class LogPointCompiler {
break;
}

// tranform property shortand `{{foo}}` to `{({foo})}`, reparse:
if (block.body.length === 1 && block.body[0].type === 'BlockStatement') {
block.body = parseSource(`(${msg.slice(start + 1, end - 2)}})`);
}

args.push(generate(this.serializeLogStatements(block.body)));
formatParts.push('%O');
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/breakpoints/breakpoints-logpoints-basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ stdout> Error: oof
at f (http://localhost:8001/logging.js:22:3)
at http://localhost:8001/logging.js:24:1
stdout> hi
stdout> {foo: 'bar'}
stdout> > {foo: 'bar'}
stdout> > arg1: {foo: 'bar'}
stdout> {f: ƒ}
stdout> > {f: ƒ}
stdout> > arg1: {f: ƒ}
2 changes: 2 additions & 0 deletions src/test/breakpoints/breakpointsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ describe('breakpoints', () => {
{ line: 12, column: 0, logMessage: '{(x=>x+baz)(bar)}' },
{ line: 13, column: 0, logMessage: '{throw new Error("oof")}' },
{ line: 14, column: 0, logMessage: "{'hi'}" },
{ line: 15, column: 0, logMessage: "{{foo: 'bar'}}" },
{ line: 16, column: 0, logMessage: '{{f}}' },
];
await p.dap.setBreakpoints({
source,
Expand Down

0 comments on commit 1c683f5

Please sign in to comment.