Repository: microsoft/vscode (TypeScript) — Bug Fix

Issue:
editor.bracketPairColorization.independentColorPoolPerBracketType stopped working after update
<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: 1.71.0
- OS Version: Ubuntu 20.04, Linux x64 5.15.0-46-generic snap

Steps to Reproduce:

1. Start VSC (possibly with extensions disabled)
2. Open any C++ workspace or any folder with C++ files.
3. Set "editor.bracketPairColorization.independentColorPoolPerBracketType": true
4. Bracket pair colorization stopped working - all brackets are yellow regardless of the nesting level or bracket type.

Version: 1.71.0
Commit: 784b0177c56c607789f9638da7b6bf3230d47a8c
Date: 2022-09-01T07:25:10.472Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Linux x64 5.15.0-46-generic snap
Sandboxed: No


Discussion:
This is weird, we didn't change anything there.
It works if you downgrade to the previous version of VS Code?
Yse, I have met the same problem after updating to 1.71.0

Same problem here on 1.71.0 on Windows 10.
Same issue here with both typescript and html templates.... 
All brackets regardless of nesting are all yellow after auto-updating to 1.71.0

Reverting to 1.70.2 and restoring synced settings from 1wk ago resolved my issue.
On an interesting note for me at least, the bracket colors are all yellow, but if I enable the guide lines they have the correct color
![VSCode-bracket-colors](https://user-images.githubusercontent.com/6640479/189424232-859d8bfe-4f48-4dc0-a7bf-9723a6d9f7ff.png)

I'm having the same issue... 
If I set `editor.bracketPairColorization.independentColorPoolPerBracketType` to `True` all brackets will always have the color defined for `editorBracketHighlight.foreground1` regardless of nesting.
Turning on or off `editor.bracketPairColorization.independentColorPoolPerBracketType` doesn't make a difference for me, though it does change how the indentation is colored. I've messed around with `true`, `false`, `"active"`, setting different brackets, etc, nothing changes the outcome, all brackets are `editorBracketHighlight.foreground1`. The indentation lines have the correct color, though.

<details>
<summary>"editor.bracketPairColorization.independentColorPoolPerBracketType": true</summary>

<img width="621" alt="image" src="https://user-images.githubusercontent.com/438465/190934188-6c323115-8e0f-4ed1-9d59-f6615a939efc.png">
</details>


<details>
<summary>"editor.bracketPairColorization.independentColorPoolPerBracketType": false</summary>

<img width="623" alt="image" src="https://user-images.githubusercontent.com/438465/190934159-1d40fe8d-8e09-4856-beed-9b21ce8f49b6.png">
</details>
Anyone up for a bugfix PR? 😉
Unfortunately, I was very busy with the merge editor this milestone.
vscode 1.72 still has this problem
I have the same issue. 
same problem in `Version: 1.72.2`

Resolving patch:
diff --git a/src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts b/src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts
--- a/src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts
+++ b/src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts
@@ -131,7 +131,7 @@ export class BracketPairsTree extends Disposable {
 		const endOffset = toLength(range.endLineNumber - 1, range.endColumn - 1);
 		return new CallbackIterable(cb => {
 			const node = this.initialAstWithoutTokens || this.astWithTokens!;
-			collectBrackets(node, lengthZero, node.length, startOffset, endOffset, cb, 0, new Map());
+			collectBrackets(node, lengthZero, node.length, startOffset, endOffset, cb, 0, 0, new Map());
 		});
 	}
 
@@ -220,6 +220,7 @@ function collectBrackets(
 	endOffset: Length,
 	push: (item: BracketInfo) => boolean,
 	level: number,
+	nestingLevelOfEqualBracketType: number,
 	levelPerBracketType: Map<string, number>
 ): boolean {
 	if (level > 200) {
@@ -248,7 +249,7 @@ function collectBrackets(
 							continue whileLoop;
 						}
 
-						const shouldContinue = collectBrackets(child, nodeOffsetStart, nodeOffsetEnd, startOffset, endOffset, push, level, levelPerBracketType);
+						const shouldContinue = collectBrackets(child, nodeOffsetStart, nodeOffsetEnd, startOffset, endOffset, push, level, 0, levelPerBracketType);
 						if (!shouldContinue) {
 							return false;
 						}
@@ -288,7 +289,7 @@ function collectBrackets(
 							continue whileLoop;
 						}
 
-						const shouldContinue = collectBrackets(child, nodeOffsetStart, nodeOffsetEnd, startOffset, endOffset, push, level + 1, levelPerBracketType);
+						const shouldContinue = collectBrackets(child, nodeOffsetStart, nodeOffsetEnd, startOffset, endOffset, push, level + 1, levelPerBracket + 1, levelPerBracketType);
 						if (!shouldContinue) {
 							return false;
 						}
@@ -306,7 +307,7 @@ function collectBrackets(
 			}
 			case AstNodeKind.Bracket: {
 				const range = lengthsToRange(nodeOffsetStart, nodeOffsetEnd);
-				return push(new BracketInfo(range, level - 1, 0, false));
+				return push(new BracketInfo(range, level - 1, nestingLevelOfEqualBracketType - 1, false));
 			}
 			case AstNodeKind.Text:
 				return true;


Test patch:
diff --git a/src/vs/editor/test/common/model/bracketPairColorizer/getBracketPairsInRange.test.ts b/src/vs/editor/test/common/model/bracketPairColorizer/getBracketPairsInRange.test.ts
--- a/src/vs/editor/test/common/model/bracketPairColorizer/getBracketPairsInRange.test.ts
+++ b/src/vs/editor/test/common/model/bracketPairColorizer/getBracketPairsInRange.test.ts
@@ -159,6 +159,91 @@ suite('Bracket Pair Colorizer - getBracketPairsInRange', () => {
 			);
 		});
 	});
+
+	test('getBracketsInRange', () => {
+		disposeOnReturn(store => {
+			const doc = new AnnotatedDocument(`¹ { [ ( [ [ (  ) ] ] ) ] } { } ²`);
+			const model = createTextModelWithColorizedBracketPairs(store, doc.text);
+			assert.deepStrictEqual(
+				model.bracketPairs
+					.getBracketsInRange(doc.range(1, 2))
+					.map(b => ({ level: b.nestingLevel, levelEqualBracketType: b.nestingLevelOfEqualBracketType, range: b.range.toString() }))
+					.toArray(),
+				[
+					{
+						level: 0,
+						levelEqualBracketType: 0,
+						range: "[1,2 -> 1,3]"
+					},
+					{
+						level: 1,
+						levelEqualBracketType: 0,
+						range: "[1,4 -> 1,5]"
+					},
+					{
+						level: 2,
+						levelEqualBracketType: 0,
+						range: "[1,6 -> 1,7]"
+					},
+					{
+						level: 3,
+						levelEqualBracketType: 1,
+						range: "[1,8 -> 1,9]"
+					},
+					{
+						level: 4,
+						levelEqualBracketType: 2,
+						range: "[1,10 -> 1,11]"
+					},
+					{
+						level: 5,
+						levelEqualBracketType: 1,
+						range: "[1,12 -> 1,13]"
+					},
+					{
+						level: 5,
+						levelEqualBracketType: 1,
+						range: "[1,15 -> 1,16]"
+					},
+					{
+						level: 4,
+						levelEqualBracketType: 2,
+						range: "[1,17 -> 1,18]"
+					},
+					{
+						level: 3,
+						levelEqualBracketType: 1,
+						range: "[1,19 -> 1,20]"
+					},
+					{
+						level: 2,
+						levelEqualBracketType: 0,
+						range: "[1,21 -> 1,22]"
+					},
+					{
+						level: 1,
+						levelEqualBracketType: 0,
+						range: "[1,23 -> 1,24]"
+					},
+					{
+						level: 0,
+						levelEqualBracketType: 0,
+						range: "[1,25 -> 1,26]"
+					},
+					{
+						level: 0,
+						levelEqualBracketType: 0,
+						range: "[1,27 -> 1,28]"
+					},
+					{
+						level: 0,
+						levelEqualBracketType: 0,
+						range: "[1,29 -> 1,30]"
+					},
+				]
+			);
+		});
+	});
 });
 
 function bracketPairToJSON(pair: BracketPairInfo): unknown {