Skip to content

Commit

Permalink
debugger: fix behavior of { a: 1 } in the debugger repl
Browse files Browse the repository at this point in the history
fix: #46808
  • Loading branch information
meixg authored and meixuguang committed Apr 24, 2024
1 parent 70e49e2 commit e2a3f35
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/internal/debugger/inspect_repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,16 @@ function createRepl(inspector) {
if (input === '\n') return lastCommand;
// Add parentheses: exec process.title => exec("process.title");
const match = RegExpPrototypeExec(/^\s*(?:exec|p)\s+([^\n]*)/, input);
input = match ? match[1] : input;

// Add parentheses to make sure input is parsed as expression
if (RegExpPrototypeExec(/^\s*{/, input) !== null &&
RegExpPrototypeExec(/;\s*$/, input) === null) {
input = `(${StringPrototypeTrim(input)})\n`;
}

if (match) {
lastCommand = `exec(${JSONStringify(match[1])})`;
lastCommand = `exec(${JSONStringify(input)})`;
} else {
lastCommand = input;
}
Expand Down

0 comments on commit e2a3f35

Please sign in to comment.