File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,17 +11,17 @@ function M.show_selected(hashes)
1111 return
1212 end
1313
14- local ordered = vim . deepcopy ( hashes )
15- table.sort ( ordered , function ( a , b )
16- return a < b
17- end )
14+ local ordered = {}
15+ for i = # hashes , 1 , - 1 do
16+ table.insert ( ordered , hashes [ i ])
17+ end
1818
1919 if # ordered == 1 then
2020 diffview_open ({ ordered [1 ] .. " ^.." .. ordered [1 ] })
2121 return
2222 end
2323
24- diffview_open (ordered )
24+ diffview_open ({ ordered [ 1 ] .. " .. " .. ordered [ # ordered ] } )
2525end
2626
2727return M
Original file line number Diff line number Diff line change 6969
7070function M .get_selected_hashes ()
7171 local hashes = {}
72- for i , ok in pairs ( M .state .selected ) do
73- if ok then
72+ for i = 1 , # M .state .commits do
73+ if M . state . selected [ i ] then
7474 local h = M .state .commits [i ]:match (" ^(%w+)" )
75- table.insert (hashes , h )
75+ if h then
76+ table.insert (hashes , h )
77+ end
7678 end
7779 end
7880 return hashes
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ T["actions"]["show_selected() diffs two commits correctly"] = function()
3434 table.insert (cmds , cmd )
3535 end
3636
37- actions .show_selected ({ " def5678 " , " abc1234 " })
38- MiniTest .expect .equality (cmds [1 ], " DiffviewOpen abc1234 def5678 " )
37+ actions .show_selected ({ " newer123 " , " older456 " })
38+ MiniTest .expect .equality (cmds [1 ], " DiffviewOpen older456..newer123 " )
3939end
4040
4141T [" log" ] = MiniTest .new_set ()
Original file line number Diff line number Diff line change @@ -43,7 +43,6 @@ T["get_selected_hashes() works"] = function()
4343 ui .state .selected [3 ] = true
4444
4545 local hashes = ui .get_selected_hashes ()
46- table.sort (hashes )
4746 MiniTest .expect .equality (hashes , { " abc1234" , " ghi9012" })
4847end
4948
You can’t perform that action at this time.
0 commit comments