@@ -155,23 +155,39 @@ function Builder:format_line(indent_markers, arrows, icon, name, node)
155155
156156 -- use the api node for user decorators
157157 local api_node = self .api_nodes and self .api_nodes [node .uid_node ] --[[ @as Node]]
158+ local u
158159
159160 local line = { indent_markers , arrows }
160161 add_to_end (line , { icon })
161162
162163 for _ , d in ipairs (self .decorators ) do
163- add_to_end (line , d :icons_before (not d :is (UserDecorator ) and node or api_node ))
164+ u = d :as (UserDecorator )
165+ if not u then
166+ add_to_end (line , d :icons_before (node ))
167+ elseif api_node then
168+ add_to_end (line , u :icons_before (api_node ))
169+ end
164170 end
165171
166172 add_to_end (line , { name })
167173
168174 for _ , d in ipairs (self .decorators ) do
169- add_to_end (line , d :icons_after (not d :is (UserDecorator ) and node or api_node ))
175+ u = d :as (UserDecorator )
176+ if not u then
177+ add_to_end (line , d :icons_after (node ))
178+ elseif api_node then
179+ add_to_end (line , u :icons_after (api_node ))
180+ end
170181 end
171182
172183 local rights = {}
173184 for _ , d in ipairs (self .decorators ) do
174- add_to_end (rights , d :icons_right_align (not d :is (UserDecorator ) and node or api_node ))
185+ u = d :as (UserDecorator )
186+ if not u then
187+ add_to_end (line , d :icons_right_align (node ))
188+ elseif api_node then
189+ add_to_end (line , u :icons_right_align (api_node ))
190+ end
175191 end
176192 if # rights > 0 then
177193 self .extmarks [self .index ] = rights
@@ -187,10 +203,17 @@ function Builder:build_signs(node)
187203 local api_node = self .api_nodes and self .api_nodes [node .uid_node ] --[[ @as Node]]
188204
189205 -- first in priority order
190- local d , sign_name
206+ local d , u , sign_name
191207 for i = # self .decorators , 1 , - 1 do
192208 d = self .decorators [i ]
193- sign_name = d :sign_name (not d :is (UserDecorator ) and node or api_node )
209+
210+ u = d :as (UserDecorator )
211+ if not u then
212+ sign_name = d :sign_name (node )
213+ elseif api_node then
214+ sign_name = u :sign_name (api_node )
215+ end
216+
194217 if sign_name then
195218 self .signs [self .index ] = sign_name
196219 break
@@ -245,11 +268,17 @@ function Builder:icon_name_decorated(node)
245268 local icon_groups = {}
246269 local name_groups = {}
247270 local hl_icon , hl_name
271+ local u
248272 for _ , d in ipairs (self .decorators ) do
249- -- maybe overridde icon
250- icon = d :icon_node ((not d :is (UserDecorator ) and node or api_node )) or icon
251-
252- hl_icon , hl_name = d :highlight_group_icon_name ((not d :is (UserDecorator ) and node or api_node ))
273+ -- maybe override icon
274+ u = d :as (UserDecorator )
275+ if not u then
276+ icon = d :icon_node (node ) or icon
277+ hl_icon , hl_name = d :highlight_group_icon_name (node )
278+ elseif api_node then
279+ icon = u :icon_node (api_node ) or icon
280+ hl_icon , hl_name = u :highlight_group_icon_name (api_node )
281+ end
253282
254283 table.insert (icon_groups , hl_icon )
255284 table.insert (name_groups , hl_name )
0 commit comments