Skip to content

Commit

Permalink
Merge pull request #881 from NeogitOrg/fix/log-popup-files
Browse files Browse the repository at this point in the history
  • Loading branch information
CKolkey authored Nov 22, 2023
2 parents 259ee2d + a82a7c8 commit 0ec50f9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
1 change: 0 additions & 1 deletion lua/neogit/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ function M.get_default_values()
"NeogitPushPopup--force-with-lease",
"NeogitPushPopup--force",
"NeogitPullPopup--rebase",
"NeogitLogPopup--",
"NeogitCommitPopup--allow-empty",
},
mappings = {
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 @@ -79,15 +79,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
10 changes: 10 additions & 0 deletions lua/neogit/popups/log/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ function M.create()
key_prefix = "-",
separator = "",
fn = actions.limit_to_files,
setup = function(popup)
local value = require("neogit.lib.state").get { "NeogitLogPopup", "" }
value = vim.split(value, " ", { trimempty = true })
value = require("neogit.lib.util").map(value, function(v)
local result, _ = v:gsub([["]], "")
return result
end)

popup.state.env.files = value
end,
})
:switch("f", "follow", "Follow renames when showing single-file log")
:arg_heading("Commit Ordering")
Expand Down

0 comments on commit 0ec50f9

Please sign in to comment.