File tree 2 files changed +31
-2
lines changed 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 115
115
116
116
M .diagnostics = function (config , node , state )
117
117
local diag = state .diagnostics_lookup or {}
118
- local diag_state = diag [ node :get_id ()]
118
+ local diag_state = utils . index_by_path ( diag , node :get_id ())
119
119
if config .hide_when_expanded and node .type == " directory" and node :is_expanded () then
120
120
return {}
121
121
end
322
322
323
323
M .modified = function (config , node , state )
324
324
local opened_buffers = state .opened_buffers or {}
325
- local buf_info = opened_buffers [ node .path ]
325
+ local buf_info = utils . index_by_path ( opened_buffers , node .path )
326
326
327
327
if buf_info and buf_info .modified then
328
328
return {
Original file line number Diff line number Diff line change @@ -1220,4 +1220,33 @@ M.brace_expand = function(s)
1220
1220
return result
1221
1221
end
1222
1222
1223
+ --- Indexes a table that uses paths as keys. Case-insensitive logic is used when
1224
+ --- running on Windows.
1225
+ ---
1226
+ --- Consideration should be taken before using this function, because it is a
1227
+ --- bit expensive on Windows. However, this function helps when trying to index
1228
+ --- with absolute path keys, which can have inconsistent casing on Windows (such
1229
+ --- as with drive letters).
1230
+ --- @param tbl table
1231
+ --- @param key string
1232
+ --- @return unknown
1233
+ M .index_by_path = function (tbl , key )
1234
+ local value = tbl [key ]
1235
+ if value ~= nil then
1236
+ return value
1237
+ end
1238
+
1239
+ -- on windows, paths that differ only by case are considered equal
1240
+ if M .is_windows then
1241
+ local key_lower = key :lower ()
1242
+ for k , v in pairs (tbl ) do
1243
+ if key_lower == k :lower () then
1244
+ return v
1245
+ end
1246
+ end
1247
+ end
1248
+
1249
+ return value
1250
+ end
1251
+
1223
1252
return M
You can’t perform that action at this time.
0 commit comments