(State) add track_winview()
This commit is contained in:
parent
e45d51cdf5
commit
03c5500966
@ -104,6 +104,7 @@ function Range.from_text_object(text_obj, opts)
|
|||||||
local positions
|
local positions
|
||||||
vim.api.nvim_buf_call(opts.buf, function()
|
vim.api.nvim_buf_call(opts.buf, function()
|
||||||
positions = State.run(0, function(s)
|
positions = State.run(0, function(s)
|
||||||
|
s:track_winview()
|
||||||
s:track_register '"'
|
s:track_register '"'
|
||||||
s:track_pos '.'
|
s:track_pos '.'
|
||||||
s:track_pos "'["
|
s:track_pos "'["
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
---@field positions table
|
---@field positions table
|
||||||
---@field keymaps { mode: string; lhs: any, rhs: any, buffer?: number }[]
|
---@field keymaps { mode: string; lhs: any, rhs: any, buffer?: number }[]
|
||||||
---@field global_options table<string, any>
|
---@field global_options table<string, any>
|
||||||
|
---@field win_view vim.fn.winsaveview.ret|nil
|
||||||
local State = {}
|
local State = {}
|
||||||
|
|
||||||
---@param buf number
|
---@param buf number
|
||||||
@ -65,6 +66,8 @@ function State:track_pos(pos) self.positions[pos] = vim.fn.getpos(pos) end
|
|||||||
---@param nm string
|
---@param nm string
|
||||||
function State:track_global_option(nm) self.global_options[nm] = vim.g[nm] end
|
function State:track_global_option(nm) self.global_options[nm] = vim.g[nm] end
|
||||||
|
|
||||||
|
function State:track_winview() self.win_view = vim.fn.winsaveview() end
|
||||||
|
|
||||||
function State:restore()
|
function State:restore()
|
||||||
for reg, val in pairs(self.registers) do
|
for reg, val in pairs(self.registers) do
|
||||||
vim.fn.setreg(reg, val)
|
vim.fn.setreg(reg, val)
|
||||||
@ -81,6 +84,7 @@ function State:restore()
|
|||||||
for nm, val in pairs(self.global_options) do
|
for nm, val in pairs(self.global_options) do
|
||||||
vim.g[nm] = val
|
vim.g[nm] = val
|
||||||
end
|
end
|
||||||
|
if self.win_view ~= nil then vim.fn.winrestview(self.win_view) end
|
||||||
end
|
end
|
||||||
|
|
||||||
return State
|
return State
|
||||||
|
Loading…
x
Reference in New Issue
Block a user