Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit ccab737

Browse files
committed
fix: Make autocompletion in REPL work
There was a bug in `internal/inspect_repl.js` that caused REPL to crash when trying to invoke autocomplete. Steps to reproduce: * Start the debugger. * Run `repl` command. * Type any letter. * Press <Tab>. * Debugger crashes with `TypeError: elem.indexOf is not a function`. The reason is that Node's REPL expects a completion group to be an array of strings while node-inspect passed an instance of ScopeSnapshot. This commit fixes it by adding completion groups for REPL as properties of ScopeSnapshot instances and returning them when evaluating ".scope".
1 parent 37cc9b7 commit ccab737

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/internal/inspect_repl.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class ScopeSnapshot {
238238
const value = new RemoteObject(prop.value);
239239
return [prop.name, value];
240240
}));
241+
this.completionGroup = properties.map((prop) => prop.name);
241242
}
242243

243244
[util.inspect.custom](depth, opts) {
@@ -480,7 +481,9 @@ function createRepl(inspector) {
480481
if (!selectedFrame) {
481482
return Promise.reject(new Error('Requires execution to be paused'));
482483
}
483-
return selectedFrame.loadScopes();
484+
return selectedFrame.loadScopes().then((scopes) => {
485+
return scopes.map((scope) => scope.completionGroup);
486+
});
484487
}
485488

486489
if (selectedFrame) {

0 commit comments

Comments
 (0)