* fix(#2878): nowrapscan prevents move from root * fix(#2878): nowrapscan prevents move from root
This commit is contained in:
committed by
GitHub
parent
210478677c
commit
42340952af
@@ -33,11 +33,15 @@ end
|
|||||||
---@param what string type of status
|
---@param what string type of status
|
||||||
---@param skip_gitignored boolean default false
|
---@param skip_gitignored boolean default false
|
||||||
local function move(where, what, skip_gitignored)
|
local function move(where, what, skip_gitignored)
|
||||||
local node_cur = lib.get_node_at_cursor()
|
|
||||||
local first_node_line = core.get_nodes_starting_line()
|
local first_node_line = core.get_nodes_starting_line()
|
||||||
local nodes_by_line = utils.get_nodes_by_line(core.get_explorer().nodes, first_node_line)
|
local nodes_by_line = utils.get_nodes_by_line(core.get_explorer().nodes, first_node_line)
|
||||||
local iter_start, iter_end, iter_step, cur, first, nex
|
local iter_start, iter_end, iter_step, cur, first, nex
|
||||||
|
|
||||||
|
local cursor = lib.get_cursor_position()
|
||||||
|
if cursor and cursor[1] < first_node_line then
|
||||||
|
cur = cursor[1]
|
||||||
|
end
|
||||||
|
|
||||||
if where == "next" then
|
if where == "next" then
|
||||||
iter_start, iter_end, iter_step = first_node_line, #nodes_by_line, 1
|
iter_start, iter_end, iter_step = first_node_line, #nodes_by_line, 1
|
||||||
elseif where == "prev" then
|
elseif where == "prev" then
|
||||||
@@ -52,7 +56,7 @@ local function move(where, what, skip_gitignored)
|
|||||||
first = line
|
first = line
|
||||||
end
|
end
|
||||||
|
|
||||||
if node == node_cur then
|
if cursor and line == cursor[1] then
|
||||||
cur = line
|
cur = line
|
||||||
elseif valid and cur then
|
elseif valid and cur then
|
||||||
nex = line
|
nex = line
|
||||||
|
|||||||
@@ -15,25 +15,33 @@ local M = {
|
|||||||
target_winid = nil,
|
target_winid = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
---@return Node|nil
|
---Cursor position as per vim.api.nvim_win_get_cursor
|
||||||
function M.get_node_at_cursor()
|
---@return integer[]|nil
|
||||||
|
function M.get_cursor_position()
|
||||||
if not core.get_explorer() then
|
if not core.get_explorer() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local winnr = view.get_winnr()
|
local winnr = view.get_winnr()
|
||||||
if not winnr then
|
if not winnr or not vim.api.nvim_win_is_valid(winnr) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local cursor = vim.api.nvim_win_get_cursor(winnr)
|
return vim.api.nvim_win_get_cursor(winnr)
|
||||||
local line = cursor[1]
|
end
|
||||||
|
|
||||||
if line == 1 and view.is_root_folder_visible(core.get_cwd()) then
|
---@return Node|nil
|
||||||
|
function M.get_node_at_cursor()
|
||||||
|
local cursor = M.get_cursor_position()
|
||||||
|
if not cursor then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if cursor[1] == 1 and view.is_root_folder_visible(core.get_cwd()) then
|
||||||
return { name = ".." }
|
return { name = ".." }
|
||||||
end
|
end
|
||||||
|
|
||||||
return utils.get_nodes_by_line(core.get_explorer().nodes, core.get_nodes_starting_line())[line]
|
return utils.get_nodes_by_line(core.get_explorer().nodes, core.get_nodes_starting_line())[cursor[1]]
|
||||||
end
|
end
|
||||||
|
|
||||||
---Create a sanitized partial copy of a node, populating children recursively.
|
---Create a sanitized partial copy of a node, populating children recursively.
|
||||||
|
|||||||
Reference in New Issue
Block a user