@@ -1356,8 +1356,8 @@ impl HighlightConfiguration {
13561356 /// Tree-sitter syntax-highlighting queries specify highlights in the form of dot-separated
13571357 /// highlight names like `punctuation.bracket` and `function.method.builtin`. Consumers of
13581358 /// these queries can choose to recognize highlights with different levels of specificity.
1359− /// For example, the string `function.builtin` will match against `function.method.builtin`
1360− /// and `function.builtin.constructor`, but will not match `function.method`.
1359+ /// For example, the string `function.builtin` will match against `function.builtin.constructor`
1360+ /// but will not match `function.method.builtin` and `function.method`.
13611361 ///
13621362 /// When highlighting, results are returned as `Highlight` values, which contain the index
13631363 /// of the matched highlight this list of highlight names.
@@ -1377,11 +1377,13 @@ impl HighlightConfiguration {
13771377 let recognized_name = recognized_name;
13781378 let mut len = 0;
13791379 let mut matches = true;
1380− for part in recognized_name.split('.') {
1381− len += 1;
1382− if !capture_parts.contains(&part) {
1383− matches = false;
1384− break;
1380+ for (i, part) in recognized_name.split('.').enumerate() {
1381+ match capture_parts.get(i) {
1382+ Some(capture_part) if *capture_part == part => len += 1,
1383+ _ => {
1384+ matches = false;
1385+ break;
1386+ }
13851387 }
13861388 }
13871389 if matches && len > best_match_len {