File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ function M.open(args)
133133 end
134134end
135135
136+
136137--- @param range ? { [1] : integer , [2] : integer }
137138--- @param args string[]
138139function M .file_history (range , args )
@@ -157,6 +158,16 @@ function M.close(tabpage)
157158 end
158159end
159160
161+ -- @param args string[]
162+ function M .toggle (args )
163+ local view = lib .get_current_view ()
164+ if view then
165+ M .close ()
166+ else
167+ M .open (args )
168+ end
169+ end
170+
160171function M .completion (_ , cmd_line , cur_pos )
161172 local ctx = arg_parser .scan (cmd_line , { cur_pos = cur_pos , allow_ex_range = true })
162173 local cmd = ctx .args [1 ]
Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ command("DiffviewOpen", function(ctx)
2424 diffview .open (arg_parser .scan (ctx .args ).args )
2525end , { nargs = " *" , complete = completion })
2626
27+ command (" DiffviewToggle" , function (ctx )
28+ diffview .toggle (arg_parser .scan (ctx .args ).args )
29+ end , { nargs = " *" , complete = completion })
30+
2731command (" DiffviewFileHistory" , function (ctx )
2832 local range
2933
You can’t perform that action at this time.
0 commit comments