microsoft / microsoft/vscode

affectsConfiguration misses changes when a longer sibling key precedes the changed key

Open
#332,614 0 comments 0 reactions 1 assignee Claimed by @sandy081 View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

### Bug description

`ChangeEvent.affectsConfiguration(section)` (`src/vs/platform/configuration/common/configurationModels.ts`) builds one padded string containing every changed key and scans for the first occurrence of `marker + section`. If that first occurrence fails the boundary check (the changed key merely extends the section name, e.g. `workbench.editorAssociations` when asking about section `workbench.editor`), the scan returns `false` immediately instead of checking later occurrences of the needle.

So a single unrelated prefix-colliding key in the change set masks a genuinely changed nested key:

```
affectedKeys = ['workbench.editorAssociations', 'workbench.editor.showTabs']
event.affectsConfiguration('workbench.editor') === false // wrong
```

With the same two keys in the opposite order the call returns `true`, which shows the result depends on insertion order.

### Steps to reproduce

1. Produce a configuration change event whose affected keys contain a longer sibling of the section before an actual child key, e.g. `workbench.editorAssociations` followed by `workbench.editor.showTabs`.
2. Ask `affectsConfiguration('workbench.editor')`.
3. It returns false even though `workbench.editor.showTabs` changed.

### Expected behavior

The scan advances through occurrences of the padded section until one passes the boundary check; the event reports true because a real child key changed, regardless of affected key order.

### Version tested

Commit `38ec3d57f91b` on `main`; reproduced with a direct unit-level repro. Existing tests only cover single-key events. A fix is ready that loops over occurrences until a boundary-valid match is found.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.