Skip to content

Commit

Permalink
Use nil check instead of metatable.
Browse files Browse the repository at this point in the history
  • Loading branch information
CKolkey committed Dec 16, 2023
1 parent 69fb64c commit c6cb986
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lua/neogit/buffers/commit_editor/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 47,7 @@ function M:open()
after = function(buffer)
local padding = util.max_length(util.flatten(vim.tbl_values(mapping)))
local pad_mapping = function(name)
return pad(mapping[name][1], padding)
return pad(mapping[name] and mapping[name][1] or "<NOP>", padding)
end

-- stylua: ignore
Expand Down
2 changes: 1 addition & 1 deletion lua/neogit/buffers/rebase_editor/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 58,7 @@ function M:open()
after = function(buffer)
local padding = util.max_length(util.flatten(vim.tbl_values(mapping)))
local pad_mapping = function(name)
return pad(mapping[name][1], padding)
return pad(mapping[name] and mapping[name][1] or "<NOP>", padding)
end

-- stylua: ignore
Expand Down
6 changes: 0 additions & 6 deletions lua/neogit/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 17,6 @@ local function get_reversed_maps(tbl)
end
end

setmetatable(result, {
__index = function()
return { "<NOP>" }
end,
})

return result
end

Expand Down

0 comments on commit c6cb986

Please sign in to comment.