microsoft / microsoft/vscode-js-debug

Completions fail when the completed name matches a variable in the enumeration template

Open
#2,399 0 comments 0 reactions 1 assignee View on GitHub

@connor4312 is already working on this.

Since Aug 25, 2026.

bug
Dominant language
TypeScript
Stars
2k
Forks
373
Avg merge
1d 9m
Merged PRs (30d)
6

Description

Problem

Completing properties on a primitive (target., 'abc'., 42.) while paused evaluates enumerateProperties as a string on the call frame using template. Code that will be evaluated is constructed on line 351.

https://github.com/microsoft/vscode-js-debug/blob/d17455cb40a09fc35ce3396896642b4f9b7bc302/src/adapter/completions.ts#L346-L367

The template binds the user expression to its own parameters:

(() => {
  let target = (target);
  let prefix = "";
  let isGlobal = false;
  // ... enumerate properties of `target`
})()

If the name being completed is also a parameter or local in that template (target, prefix, isGlobal, or a minified name like n), the inner target refers to the template binding instead of the user variable. Evaluation throws and completions are empty.

This does not affect objects: they are enumerated with Runtime.callFunctionOn on an objectId, so the helper never runs as source in the call frame.

In the currently released version, the following completion won't work because of described error (minified extension sources contain variable named n):

let n = 1
debugger
// n.
Proposed fix

The first evaluate already returned the primitive. Interpolate that value into the template (let target = 1) and run it with Runtime.evaluate (no call frame). The template no longer reads locals, so names cannot clash.

VS Code Version: 1.134.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.