fix: clear last line
This commit is contained in:
@@ -246,6 +246,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
builtin.fd = function(opts)
|
builtin.fd = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
local fd_string = nil
|
local fd_string = nil
|
||||||
if 1 == vim.fn.executable("fd") then
|
if 1 == vim.fn.executable("fd") then
|
||||||
fd_string = "fd"
|
fd_string = "fd"
|
||||||
@@ -258,9 +260,23 @@ builtin.fd = function(opts)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO: CWD not 100% supported at this moment.
|
||||||
|
-- Previewers don't work. We'll have to try out something for that later
|
||||||
|
local cwd = opts.cwd
|
||||||
|
if cwd then
|
||||||
|
cwd = vim.fn.expand(cwd)
|
||||||
|
end
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers.new(opts, {
|
||||||
prompt = 'Find Files',
|
prompt = 'Find Files',
|
||||||
finder = finders.new_oneshot_job {fd_string},
|
finder = finders.new {
|
||||||
|
fn_command = function()
|
||||||
|
return {
|
||||||
|
command = fd_string,
|
||||||
|
cwd = cwd,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
previewer = previewers.cat,
|
previewer = previewers.cat,
|
||||||
sorter = sorters.get_fuzzy_file(),
|
sorter = sorters.get_fuzzy_file(),
|
||||||
}):find()
|
}):find()
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ function Finder:_find(prompt, process_result, process_complete)
|
|||||||
self.job = Job:new {
|
self.job = Job:new {
|
||||||
command = opts.command,
|
command = opts.command,
|
||||||
args = opts.args,
|
args = opts.args,
|
||||||
|
cwd = opts.cwd,
|
||||||
|
|
||||||
maximum_results = self.maximum_results,
|
maximum_results = self.maximum_results,
|
||||||
|
|
||||||
|
|||||||
@@ -231,6 +231,10 @@ function Picker:find()
|
|||||||
local selection_strategy = self.selection_strategy or 'reset'
|
local selection_strategy = self.selection_strategy or 'reset'
|
||||||
|
|
||||||
local on_lines = function(_, _, _, first_line, last_line)
|
local on_lines = function(_, _, _, first_line, last_line)
|
||||||
|
if not vim.api.nvim_buf_is_valid(prompt_bufnr) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local prompt = vim.api.nvim_buf_get_lines(prompt_bufnr, first_line, last_line, false)[1]
|
local prompt = vim.api.nvim_buf_get_lines(prompt_bufnr, first_line, last_line, false)[1]
|
||||||
|
|
||||||
self.manager = pickers.entry_manager(
|
self.manager = pickers.entry_manager(
|
||||||
@@ -306,7 +310,7 @@ function Picker:find()
|
|||||||
self:set_selection(self.max_results)
|
self:set_selection(self.max_results)
|
||||||
end
|
end
|
||||||
|
|
||||||
local worst_line = self.max_results - self.manager.num_results()
|
local worst_line = self.max_results - self.manager.num_results() + 1
|
||||||
if worst_line <= 0 then
|
if worst_line <= 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -448,12 +452,22 @@ function Picker:reset_selection()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Picker:set_selection(row)
|
function Picker:set_selection(row)
|
||||||
|
-- TODO: Loop around behavior?
|
||||||
|
-- TODO: Scrolling past max results
|
||||||
if row > self.max_results then
|
if row > self.max_results then
|
||||||
row = self.max_results
|
row = self.max_results
|
||||||
elseif row < 1 then
|
elseif row < 1 then
|
||||||
row = 1
|
row = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO: Move max results and row and entry management into an overridable funciton.
|
||||||
|
-- I have this same thing copied all over the place (and it's not good).
|
||||||
|
-- Particularly if we're going to do something like make it possible to sort
|
||||||
|
-- top to bottom, rather than bottom to top.
|
||||||
|
if row < (self.max_results - self.manager:num_results() + 1) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local entry = self.manager:get_entry(self.max_results - row + 1)
|
local entry = self.manager:get_entry(self.max_results - row + 1)
|
||||||
local status = state.get_status(self.prompt_bufnr)
|
local status = state.get_status(self.prompt_bufnr)
|
||||||
local results_bufnr = status.results_bufnr
|
local results_bufnr = status.results_bufnr
|
||||||
|
|||||||
Reference in New Issue
Block a user