Skip to content

Commit

Permalink
Merge pull request #882 from NeogitOrg/remove-ignored-setting
Browse files Browse the repository at this point in the history
  • Loading branch information
CKolkey authored Nov 22, 2023
2 parents 91a2655 + b4f9427 commit a4a45a4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 0 additions & 2 deletions lua/neogit/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ function M.get_default_values()
"NeogitPushPopup--force-with-lease",
"NeogitPushPopup--force",
"NeogitPullPopup--rebase",
"NeogitLogPopup--",
"NeogitCommitPopup--allow-empty",
"NeogitRevertPopup--no-edit", -- TODO: Fix incompatible switches with default enables
},
mappings = {
finder = {
Expand Down
4 changes: 4 additions & 0 deletions lua/neogit/lib/popup/builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ function M:option(key, cli, value, description, opts)
opts.separator = "="
end

if opts.setup then
opts.setup(self)
end

table.insert(self.state.args, {
type = "option",
id = opts.key_prefix .. key,
Expand Down
12 changes: 9 additions & 3 deletions lua/neogit/lib/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,21 @@ local function gen_key(key_table)
end

---Set option and write to disk
---@param key table
---@param key string[]
---@param value any
function M.set(key, value)
if not M.enabled() then
return
end

if not vim.tbl_contains(config.values.ignored_settings, gen_key(key)) then
M.state[gen_key(key)] = value
local cache_key = gen_key(key)
if not vim.tbl_contains(config.values.ignored_settings, cache_key) then
if value == "" then
M.state[cache_key] = nil
else
M.state[cache_key] = value
end

M.write()
end
end
Expand Down
12 changes: 12 additions & 0 deletions lua/neogit/popups/log/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ function M.create()
key_prefix = "-",
separator = "",
fn = actions.limit_to_files,
setup = function(popup)
local state = require("neogit.lib.state").get { "NeogitLogPopup", "" }
if state then
-- State for this option is saved with quotes around each filepath, which cannot
-- get passed into the CLI lib. So, to handle things internally, we need to strip
-- them out when loading the popup.
popup.state.env.files = vim.tbl_map(function(value)
local result, _ = value:gsub([["]], "")
return result
end, vim.split(state, " ", { trimempty = true }))
end
end,
})
:switch("f", "follow", "Follow renames when showing single-file log")
:arg_heading("Commit Ordering")
Expand Down

0 comments on commit a4a45a4

Please sign in to comment.