mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-16 11:00:23 +00:00
feat(shorten_list) Is now super useful
This commit is contained in:
parent
eaf39b775d
commit
37a9cefe32
@ -101,7 +101,8 @@ M.add_file = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.store_offset = function()
|
M.store_offset = function()
|
||||||
local idx = get_id_or_current_buffer()
|
local id = get_id_or_current_buffer()
|
||||||
|
local idx = get_index_of(id)
|
||||||
if not valid_index(idx) then
|
if not valid_index(idx) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -110,8 +111,8 @@ M.store_offset = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.swap = function(a, b)
|
M.swap = function(a, b)
|
||||||
a_idx = get_index_of(a)
|
local a_idx = get_index_of(a)
|
||||||
b_idx = get_index_of(get_id_or_current_buffer(b))
|
local b_idx = get_index_of(get_id_or_current_buffer(b))
|
||||||
|
|
||||||
if not valid_index(a_idx) or not valid_index(b_idx) then
|
if not valid_index(a_idx) or not valid_index(b_idx) then
|
||||||
return
|
return
|
||||||
@ -121,8 +122,8 @@ M.swap = function(a, b)
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.rm_file = function()
|
M.rm_file = function()
|
||||||
id = get_id_or_current_buffer()
|
local id = get_id_or_current_buffer()
|
||||||
idx = get_index_of(id)
|
local idx = get_index_of(id)
|
||||||
|
|
||||||
if not valid_index(idx) then
|
if not valid_index(idx) then
|
||||||
return
|
return
|
||||||
@ -131,13 +132,17 @@ M.rm_file = function()
|
|||||||
marked_files[idx] = nil
|
marked_files[idx] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.trim = function()
|
||||||
|
M.shorten_list(idx)
|
||||||
|
end
|
||||||
|
|
||||||
M.clear_all = function()
|
M.clear_all = function()
|
||||||
marked_files = {}
|
marked_files = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
M.promote = function(id)
|
M.promote = function(id)
|
||||||
id = get_id_or_current_buffer(id)
|
local id = get_id_or_current_buffer(id)
|
||||||
idx = get_index_of(id)
|
local idx = get_index_of(id)
|
||||||
|
|
||||||
if not valid_index(idx) or idx == 1 then
|
if not valid_index(idx) or idx == 1 then
|
||||||
return
|
return
|
||||||
@ -169,6 +174,17 @@ M.remove_nils = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.shorten_list = function(count)
|
M.shorten_list = function(count)
|
||||||
|
if not count then
|
||||||
|
local id = get_id_or_current_buffer()
|
||||||
|
local idx = get_index_of(id)
|
||||||
|
|
||||||
|
if not valid_index(idx) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
count = idx
|
||||||
|
end
|
||||||
|
|
||||||
local next = {}
|
local next = {}
|
||||||
local up_to = math.min(count, #marked_files)
|
local up_to = math.min(count, #marked_files)
|
||||||
for idx = 1, up_to do
|
for idx = 1, up_to do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user