From 4b0609840b6ba78e7b9c0e4b7e772914a8cb311d Mon Sep 17 00:00:00 2001 From: Kai Ren Date: Thu, 28 Aug 2025 17:40:48 +0200 Subject: [PATCH] go: Fix highlighting of fields (#37026) Closes #36420 ## Synopsis The issue in #36420 is caused by #7276, which bound the appropriate tree-sitter queries to the `@variable.member` color. However, I have found neither this color's declaration nor its other usages in the codebase (neither on the latest `main` nor on 79c1003b344ee513cf97ee8313c38c7c3f02c916). Other languages use for such situations the `@property` color. ## Solution Just change the used `@variable.member` color to the `@property` one. Seems fully inline with the changes illustrated in #7276. ## Screenshots Screenshot 2025-08-28 at 13 18 38 Screenshot 2025-08-28 at 13 20 08 ## Changelog Release Notes: - go: Fixed highlighting of fields. --- crates/languages/src/go.rs | 3 ++- crates/languages/src/go/highlights.scm | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/languages/src/go.rs b/crates/languages/src/go.rs index 24e2ca2f56..86f8e1faaa 100644 --- a/crates/languages/src/go.rs +++ b/crates/languages/src/go.rs @@ -764,6 +764,7 @@ mod tests { let highlight_type = grammar.highlight_id_for_name("type").unwrap(); let highlight_keyword = grammar.highlight_id_for_name("keyword").unwrap(); let highlight_number = grammar.highlight_id_for_name("number").unwrap(); + let highlight_field = grammar.highlight_id_for_name("property").unwrap(); assert_eq!( adapter @@ -828,7 +829,7 @@ mod tests { Some(CodeLabel { text: "two.Three a.Bcd".to_string(), filter_range: 0..9, - runs: vec![(12..15, highlight_type)], + runs: vec![(4..9, highlight_field), (12..15, highlight_type)], }) ); } diff --git a/crates/languages/src/go/highlights.scm b/crates/languages/src/go/highlights.scm index 5aa23fca90..bb0eaab88a 100644 --- a/crates/languages/src/go/highlights.scm +++ b/crates/languages/src/go/highlights.scm @@ -1,13 +1,13 @@ (identifier) @variable (type_identifier) @type -(field_identifier) @variable.member +(field_identifier) @property (package_identifier) @namespace (keyed_element . (literal_element - (identifier) @variable.member)) + (identifier) @property)) (call_expression function: (identifier) @function)