Skip to content

Commit

Permalink
fix: removing some gotos and maybe fixing ci
Browse files Browse the repository at this point in the history
  • Loading branch information
wllfaria committed Aug 16, 2024
1 parent f1ebdc2 commit c29253a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
21 changes: 11 additions & 10 deletions lua/ledger/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@ function M.get_missing_accounts()
for filename, postings in pairs(context.postings) do
for _, posting in pairs(postings) do
local account_name = posting.account.text
local has_account = false

for _, accounts in pairs(context.accounts) do
if vim.tbl_contains(accounts, account_name) then
goto continue
has_account = true
end
end

if not missing_accounts[filename] then
missing_accounts[filename] = {}
if not has_account then
if not missing_accounts[filename] then
missing_accounts[filename] = {}
end
table.insert(missing_accounts[filename], {
filename = filename,
text = account_name,
range = posting.account.range,
})
end
table.insert(missing_accounts[filename], {
filename = filename,
text = account_name,
range = posting.account.range,
})

::continue::
end
end

Expand Down
8 changes: 4 additions & 4 deletions lua/ledger/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ function M.tbl_merge(behavior, table_a, table_b)
local has_key = result[key] ~= nil
if has_key and behavior == "error" then
error("duplicate key (" .. key .. ") on right side table")
elseif has_key and behavior == "keep" then
goto continue
elseif has_key and behavior == "force" then
result[key] = value
elseif not has_key then
result[key] = value
end
result[key] = value
end
::continue::
end

return result
Expand Down
1 change: 1 addition & 0 deletions lua/tests/parser_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ describe("parser", function()
local parser = require("ledger.parser")

before_each(function()
require("nvim-treesitter.install").ensure_installed("ledger")
vim.cmd.enew()
vim.bo.filetype = "ledger"
end)
Expand Down

0 comments on commit c29253a

Please sign in to comment.