ensure normal-mode before running g@...
All checks were successful
NeoVim tests / code-quality (push) Successful in 1m21s
All checks were successful
NeoVim tests / code-quality (push) Successful in 1m21s
This commit is contained in:
parent
81ba1bb96b
commit
6f86bfaa42
@ -1,5 +1,7 @@
|
||||
local Pos = require 'u.pos'
|
||||
|
||||
local ESC = vim.api.nvim_replace_termcodes('<Esc>', true, false, true)
|
||||
|
||||
--- @class u.Range
|
||||
--- @field start u.Pos
|
||||
--- @field stop u.Pos|nil
|
||||
@ -132,6 +134,8 @@ function Range.from_motion(motion, opts)
|
||||
pos_rbrack = vim.fn.getpos "']",
|
||||
opfunc = vim.go.operatorfunc,
|
||||
prev_captured_range = _G.Range__from_motion_opfunc_captured_range,
|
||||
prev_mode = vim.fn.mode(),
|
||||
vinf = Range.from_vtext(),
|
||||
}
|
||||
--- @type u.Range|nil
|
||||
_G.Range__from_motion_opfunc_captured_range = nil
|
||||
@ -146,7 +150,7 @@ function Range.from_motion(motion, opts)
|
||||
vim.cmd {
|
||||
cmd = 'normal',
|
||||
bang = not opts.user_defined,
|
||||
args = { 'g@' .. motion },
|
||||
args = { ESC .. 'g@' .. motion },
|
||||
mods = { silent = true },
|
||||
}
|
||||
end)
|
||||
@ -158,6 +162,7 @@ function Range.from_motion(motion, opts)
|
||||
vim.fn.setpos('.', original_state.cursor)
|
||||
vim.fn.setpos("'[", original_state.pos_lbrack)
|
||||
vim.fn.setpos("']", original_state.pos_rbrack)
|
||||
if original_state.prev_mode ~= 'n' then original_state.vinf:set_visual_selection() end
|
||||
vim.go.operatorfunc = original_state.opfunc
|
||||
_G.Range__from_motion_opfunc_captured_range = original_state.prev_captured_range
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
{
|
||||
pkgs ?
|
||||
import
|
||||
# neovim@0.11.1: https://history.nix-packages.com/package/neovim/0.11.1
|
||||
(fetchTarball "https://github.com/nixos/nixpkgs/tarball/e73c3bf29132da092f9c819b97b6e214367eb71f")
|
||||
# nixpkgs-unstable (neovim@0.11.2):
|
||||
(fetchTarball {
|
||||
url = "https://github.com/nixos/nixpkgs/archive/e4b09e47ace7d87de083786b404bf232eb6c89d8.tar.gz";
|
||||
sha256 = "1a2qvp2yz8j1jcggl1yvqmdxicbdqq58nv7hihmw3bzg9cjyqm26";
|
||||
})
|
||||
{ },
|
||||
}:
|
||||
pkgs.mkShell {
|
||||
|
Loading…
x
Reference in New Issue
Block a user