Skip to content

health check reports .vscode settings loaded on empty directory #653

@mrcjkb

Description

@mrcjkb

Looking at this:

local function find_vscode_settings(bufname)
local settings = {}
local found_dirs = vim.fs.find({ '.vscode' }, { upward = true, path = vim.fs.dirname(bufname), type = 'directory' })
if vim.tbl_isempty(found_dirs) then
return settings
end

If I run this:

vim.fs.find({ '.vscode' }, { upward = true, path = vim.fs.dirname(bufname), type = 'directory' })

It returns an empty table. Which then returns an empty table here:

if vim.tbl_isempty(found_dirs) then
return settings
end

That is used here:

if config.server.load_vscode_settings then
local json_settings = find_vscode_settings(bufname)
require('rustaceanvim.config.json').override_with_rust_analyzer_json_keys(evaluated_settings, json_settings)
end

Which triggers this:

function M.override_with_rust_analyzer_json_keys(tbl, json_tbl)
M.override_with_json_keys(tbl, json_tbl, function(key)
return vim.startswith(key, 'rust-analyzer')
end)
end

Which triggers this:

function M.override_with_json_keys(tbl, json_tbl, key_predicate)
is_json_config_loaded = true
for json_key, value in pairs(json_tbl) do
if not key_predicate or key_predicate(json_key) then
override_tbl_values(tbl, json_key, value)
end
end
end

Which then sets is_json_config_loaded = true, even though it was an empty table because there was no JSON.

That then triggers the "loaded vscode json" message in the healthcheck. So I don't believe that's relevant in this case, unless the fact that it things an (empty) vscode file was loaded makes it not inject the check config, but I haven't checked if that's the case.

Originally posted by @JeanMertz in #652 (reply in thread)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions