Skip to content

Commit 1b778b6

Browse files
authored
fix: misc. minor big fixes (#20)
* Clear loading flags on error in update_files to prevent the file panel from getting stuck showing "Fetching changes...". * Fix misleading "clipboard" message for copy_hash (uses unnamed reg). * Fix Windows cmd /c start empty title arg for open_commit_in_browser. * Guard against empty resolved layout list in cycle_layout to prevent division-by-zero when config contains only unknown layout names.
1 parent 1897fb3 commit 1b778b6

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

lua/diffview/actions.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -607,13 +607,15 @@ function M.cycle_layout()
607607
end
608608

609609
-- Use config or fall back to defaults.
610+
local default_standard = { Diff2Hor.__get(), Diff2Ver.__get() }
611+
local default_merge_tool = { Diff3Hor.__get(), Diff3Ver.__get(), Diff3Mixed.__get(), Diff4Mixed.__get(), Diff1.__get() }
612+
613+
local resolved_standard = resolve_layouts(cycle_config.default)
614+
local resolved_merge_tool = resolve_layouts(cycle_config.merge_tool)
615+
610616
local layout_cycles = {
611-
standard = #(cycle_config.default or {}) > 0
612-
and resolve_layouts(cycle_config.default)
613-
or { Diff2Hor.__get(), Diff2Ver.__get() },
614-
merge_tool = #(cycle_config.merge_tool or {}) > 0
615-
and resolve_layouts(cycle_config.merge_tool)
616-
or { Diff3Hor.__get(), Diff3Ver.__get(), Diff3Mixed.__get(), Diff4Mixed.__get(), Diff1.__get() },
617+
standard = #resolved_standard > 0 and resolved_standard or default_standard,
618+
merge_tool = #resolved_merge_tool > 0 and resolved_merge_tool or default_merge_tool,
617619
}
618620

619621
local view = lib.get_current_view()

lua/diffview/scene/views/diff/diff_view.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ DiffView.update_files = debounce.debounce_trailing(
389389
if err then
390390
utils.err("Failed to update files in a diff view!", true)
391391
logger:error("[DiffView] Failed to update files!")
392+
self.is_loading = false
393+
self.panel.is_loading = false
394+
self.panel:render()
395+
self.panel:redraw()
392396
callback(err)
393397
return
394398
end

lua/diffview/scene/views/file_history/listeners.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ return function(view)
269269
local item = view.panel:get_item_at_cursor()
270270
if item then
271271
vim.fn.setreg('"', item.commit.hash)
272-
utils.info(string.format("Copied '%s' to the clipboard.", item.commit.hash))
272+
utils.info(string.format("Copied '%s' to the default register.", item.commit.hash))
273273
end
274274
end
275275
end,
@@ -299,7 +299,7 @@ return function(view)
299299
elseif vim.fn.has("unix") == 1 then
300300
cmd = { "xdg-open", url }
301301
elseif vim.fn.has("win32") == 1 then
302-
cmd = { "cmd", "/c", "start", '""', url }
302+
cmd = { "cmd", "/c", "start", "", url }
303303
end
304304

305305
if cmd then

0 commit comments

Comments
 (0)