@@ -143,11 +143,7 @@ function Builder:_build_folder(node, padding, git_hl, git_icons_tbl)
143
143
local git_icons = self :_unwrap_git_data (git_icons_tbl , offset + # icon + (self .is_git_after and # foldername + 1 or 0 ))
144
144
local modified_icon = self :_get_modified_icon (node )
145
145
146
- -- TODO: this is duplicated logic with _build_file & _build_symlink
147
- local fname_starts_at = offset
148
- + # icon
149
- + (self .is_git_after and 0 or # git_icons )
150
- + (self .modified .placement ~= " before" and 0 or # modified_icon )
146
+ local fname_starts_at = self ._get_filename_offset (offset , icon , git_icons , modified_icon )
151
147
local line = self :_format_line (padding .. icon , foldername , git_icons , modified_icon )
152
148
self :_insert_line (line )
153
149
@@ -197,6 +193,18 @@ function Builder:_format_line(before, after, git_icons, modified_icon)
197
193
)
198
194
end
199
195
196
+ --- @param offset integer
197
+ --- @param icon string
198
+ --- @param git_icons string
199
+ --- @param modified_icon string
200
+ --- @return integer
201
+ function Builder :_get_filename_offset (offset , icon , git_icons , modified_icon )
202
+ return offset
203
+ + # icon
204
+ + (self .is_git_after and 0 or # git_icons )
205
+ + (self .modified .placement ~= " before" and 0 or # modified_icon )
206
+ end
207
+
200
208
function Builder :_build_symlink (node , padding , git_highlight , git_icons_tbl )
201
209
local offset = string.len (padding )
202
210
@@ -217,6 +225,7 @@ function Builder:_build_symlink(node, padding, git_highlight, git_icons_tbl)
217
225
218
226
self :_insert_highlight (
219
227
link_highlight ,
228
+ -- TODO: is this a bug? where's icon?
220
229
offset + (self .is_git_after and 0 or # git_icons ) + (self .modified .placement ~= " before" and 0 or # modified_icon ),
221
230
string.len (line )
222
231
)
@@ -258,9 +267,7 @@ function Builder:_build_file(node, padding, git_highlight, git_icons_tbl, unload
258
267
local modified_icon = self :_get_modified_icon (node )
259
268
self :_insert_line (self :_format_line (padding .. icon , node .name , git_icons , modified_icon ))
260
269
261
- local git_icons_length = self .is_git_after and 0 or # git_icons
262
- local modified_icon_length = self .modified .placement ~= " before" and 0 or # modified_icon
263
- local col_start = offset + # icon + git_icons_length + modified_icon_length
270
+ local col_start = self ._get_filename_offset (offset , icon , git_icons , modified_icon )
264
271
local col_end = col_start + # node .name
265
272
266
273
if vim .tbl_contains (self .special_files , node .absolute_path ) or vim .tbl_contains (self .special_files , node .name ) then
@@ -275,7 +282,7 @@ function Builder:_build_file(node, padding, git_highlight, git_icons_tbl, unload
275
282
and vim .fn .bufloaded (node .absolute_path ) > 0
276
283
and vim .fn .bufnr (node .absolute_path ) ~= unloaded_bufnr
277
284
if should_highlight_opened_files then
278
- self :_highlight_opened_files (node , offset , # icon , git_icons_length )
285
+ self :_highlight_opened_files (node , offset , # icon , self . is_git_after and 0 or # git_icons )
279
286
end
280
287
281
288
if git_highlight then
0 commit comments