mirror of
https://github.com/neovim/neovim.git
synced 2026-07-10 11:29:39 +00:00
fix(dir): select origin on parent navigation #40658
This commit is contained in:
@@ -158,7 +158,11 @@ end
|
||||
|
||||
---@param buf integer
|
||||
local function open_parent(buf)
|
||||
navigate(fs.dirname(api.nvim_buf_get_name(buf)))
|
||||
local path = api.nvim_buf_get_name(buf)
|
||||
-- TODO(barrettruth): simplify after #40552
|
||||
local name = encode_name(fs.basename(path)) .. (vim.fn.isdirectory(path) == 1 and '/' or '')
|
||||
navigate(fs.dirname(path))
|
||||
vim.fn.search([[\C\m^\V]] .. vim.fn.escape(name, [[\]]) .. [[\m$]], 'cw')
|
||||
end
|
||||
|
||||
function M._open_entry()
|
||||
|
||||
@@ -155,6 +155,9 @@ describe('nvim.dir', function()
|
||||
assert_directory(root)
|
||||
line_of('alpha.txt')
|
||||
|
||||
-- Ensure the cursor stays on the entry we navigated up from.
|
||||
eq('alpha.txt', api.nvim_get_current_line())
|
||||
|
||||
n.clear({ args_rm = { '--cmd' }, args = { '--noplugin' } })
|
||||
api.nvim_buf_set_lines(0, 0, -1, false, { ' alpha', ' beta' })
|
||||
api.nvim_win_set_cursor(0, { 2, 7 })
|
||||
|
||||
Reference in New Issue
Block a user