mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor(defaults): use getregion() for default * and # mappings
This commit is contained in:
parent
df1795cd6b
commit
eb4783fb6c
@ -4,27 +4,9 @@ do
|
|||||||
---
|
---
|
||||||
--- See |v_star-default| and |v_#-default|
|
--- See |v_star-default| and |v_#-default|
|
||||||
do
|
do
|
||||||
local function region_chunks(region)
|
|
||||||
local chunks = {}
|
|
||||||
local maxcol = vim.v.maxcol
|
|
||||||
for line, cols in vim.spairs(region) do
|
|
||||||
local endcol = cols[2] == maxcol and -1 or cols[2]
|
|
||||||
local chunk = vim.api.nvim_buf_get_text(0, line, cols[1], line, endcol, {})[1]
|
|
||||||
table.insert(chunks, chunk)
|
|
||||||
end
|
|
||||||
return chunks
|
|
||||||
end
|
|
||||||
|
|
||||||
local function _visual_search(cmd)
|
local function _visual_search(cmd)
|
||||||
assert(cmd == '/' or cmd == '?')
|
assert(cmd == '/' or cmd == '?')
|
||||||
local region = vim.region(
|
local chunks = vim.fn.getregion('.', 'v', vim.fn.mode())
|
||||||
0,
|
|
||||||
'.',
|
|
||||||
'v',
|
|
||||||
vim.api.nvim_get_mode().mode:sub(1, 1),
|
|
||||||
vim.o.selection == 'inclusive'
|
|
||||||
)
|
|
||||||
local chunks = region_chunks(region)
|
|
||||||
local esc_chunks = vim
|
local esc_chunks = vim
|
||||||
.iter(chunks)
|
.iter(chunks)
|
||||||
:map(function(v)
|
:map(function(v)
|
||||||
|
Loading…
Reference in New Issue
Block a user