From 58d9a0393ecc16f543538d61201757ad0d8ef429 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Sun, 14 Jan 2024 10:09:21 -0800 Subject: [PATCH] [symbol-provider-tree-sitter] Fix icon display via `symbol.icon` Specifying the icon via the `(#set! symbol.icon "foo")` predicate was having no effect. --- packages/symbol-provider-tree-sitter/README.md | 2 ++ .../symbol-provider-tree-sitter/lib/capture-organizer.js | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/symbol-provider-tree-sitter/README.md b/packages/symbol-provider-tree-sitter/README.md index 0d2d00567..9ef72458b 100644 --- a/packages/symbol-provider-tree-sitter/README.md +++ b/packages/symbol-provider-tree-sitter/README.md @@ -179,3 +179,5 @@ If this value is omitted, this provider will still attempt to match certain comm The `symbol.tag` predicate will set the value of a symbol’s `tag` property to a fixed string. The `tag` property is used to supply a word that represents the symbol in some way. For conventional symbols, this will often be something like `class` or `function`. + +This provider will attempt to match certain common tag values to icons. This can be overridden by specifying an explicit `symbol.icon` value. diff --git a/packages/symbol-provider-tree-sitter/lib/capture-organizer.js b/packages/symbol-provider-tree-sitter/lib/capture-organizer.js index ef7a926f7..9086bb149 100644 --- a/packages/symbol-provider-tree-sitter/lib/capture-organizer.js +++ b/packages/symbol-provider-tree-sitter/lib/capture-organizer.js @@ -246,11 +246,11 @@ class Name { } toSymbol() { - let { name, shortName, position, context, tag } = this; - let symbol = { name, shortName, position }; + let { name, shortName, position, context, tag, icon } = this; + let symbol = { name, shortName, position, icon }; if (tag) { symbol.tag = tag; - symbol.icon = iconForTag(tag); + symbol.icon ??= iconForTag(tag); } if (context) symbol.context = context;