mirror of
https://github.com/neovim/neovim.git
synced 2026-08-03 06:09:14 +00:00
feat(pos): vim.pos.cursor() without args returns curwin pos #40975
This commit is contained in:
@@ -166,7 +166,8 @@ end
|
||||
--- Creates a new |vim.Pos| from cursor position (see |api-indexing|).
|
||||
---
|
||||
--- If {pos} is omitted, the first argument is treated as {win} instead of {buf},
|
||||
--- and the current cursor position of {win} is used.
|
||||
--- and the current cursor position of {win} is used. If {win} is also omitted,
|
||||
--- it defaults to the current window.
|
||||
---
|
||||
--- Example:
|
||||
--- ```lua
|
||||
@@ -179,7 +180,7 @@ end
|
||||
---@param buf integer
|
||||
---@param pos [integer, integer] (lnum, col) tuple
|
||||
---@return vim.Pos
|
||||
---@overload fun(win: integer): vim.Pos
|
||||
---@overload fun(win?: integer): vim.Pos
|
||||
function M.cursor(buf, pos)
|
||||
validate('pos', pos, 'table', true)
|
||||
|
||||
@@ -190,8 +191,8 @@ function M.cursor(buf, pos)
|
||||
end
|
||||
else
|
||||
local win = buf
|
||||
validate('win', win, 'number')
|
||||
if win == 0 then
|
||||
validate('win', win, 'number', true)
|
||||
if win == 0 or win == nil then
|
||||
win = api.nvim_get_current_win()
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user