Modify the idGenerator - #333905
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Counter wrapping introduces duplicate IDs that can overwrite active resources.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/vs/base/common/idGenerator.ts — The modulo makes IDs repeat after 1,000 calls, violating the generator's uniqueness contract. This… |
What changed in this PR
Changes the shared ID generator to cycle numeric suffixes every 1,000 IDs.
Changes:
- Adds modulo-based counter wrapping.
| File | Description |
|---|---|
src/vs/base/common/idGenerator.ts |
Wraps generated IDs at 1,000. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| this._lastId = (this._lastId + 1) % 1000; | ||
| return this._prefix + this._lastId; |
991c6ac to
57578b5
Compare
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Wrapping introduces duplicate IDs for consumers that require uniqueness.
Review tier: Balanced
Findings: 1
Pre-existing issues (1)
| Severity | Finding |
|---|---|
src/vs/base/common/idGenerator.ts — The modulo makes IDs repeat after 1,000 calls, violating the generator's uniqueness contract. This… View comment |
Suppressed comments (1)
src/vs/base/common/idGenerator.ts:18
- The modulo makes IDs repeat every 1,000 calls (and changes the 1,000th ID to
prefix0). This generator is used where IDs must remain unique—for example,OneReference.idis the tree identity andTextEditorDecorationTypekeys may remain registered—so a large reference result or a long-running extension host can collide with a live object and overwrite/misidentify it. Keep the counter monotonic rather than wrapping it.
this._lastId = (this._lastId + 1) % 1000;
return this._prefix + this._lastId;
<!-- Thank you for submitting a Pull Request. Please: * Read our Pull Request guidelines: https://github.com/microsoft/vscode/wiki/How-to-Contribute#pull-requests * Associate an issue with the Pull Request. * Ensure that the code is up-to-date with the `main` branch. * Include a description of the proposed changes and how to test them. -->
57578b5 to
fec1fee
Compare
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Wrapping generates duplicate IDs and breaks callers that require uniqueness.
Review tier: Balanced
Findings: 1
Pre-existing issues (1)
| Severity | Finding |
|---|---|
src/vs/base/common/idGenerator.ts — The modulo makes IDs repeat after 1,000 calls, violating the generator's uniqueness contract. This… View comment |
Suppressed comments (1)
src/vs/base/common/idGenerator.ts:18
- This makes a process-wide ID generator repeat values after 1,000 calls, violating the uniqueness its callers rely on. For example,
TextEditorDecorationTypeuses a static generator for registration keys; the 1,001st decoration will reuse the first key, and disposing either instance can unregister the other. Keep the counter monotonic rather than wrapping it.
this._lastId = (this._lastId + 1) % 1000;
return this._prefix + this._lastId;

No description provided.