forked from mirror/codesnap.nvim
[Chore] fix code style by stylua (#13)
parent
dab5602ac8
commit
d60a491d3f
|
@ -9,12 +9,12 @@ function visual_utils.get_selected_text()
|
||||||
if start_pos[2] > end_pos[2] or start_pos[3] > end_pos[3] then
|
if start_pos[2] > end_pos[2] or start_pos[3] > end_pos[3] then
|
||||||
start_pos, end_pos = end_pos, start_pos
|
start_pos, end_pos = end_pos, start_pos
|
||||||
end
|
end
|
||||||
|
|
||||||
if start_pos[2] == end_pos[2] then
|
if start_pos[2] == end_pos[2] then
|
||||||
return vim.api.nvim_buf_get_lines(0, start_pos[2] - 1, start_pos[2], false)[1]:sub(start_pos[3], end_pos[3] - 1)
|
return vim.api.nvim_buf_get_lines(0, start_pos[2] - 1, start_pos[2], false)[1]:sub(start_pos[3], end_pos[3] - 1)
|
||||||
else
|
else
|
||||||
-- 如果选中的是多行文本,则需要分别获取每一行的文本
|
-- 如果选中的是多行文本,则需要分别获取每一行的文本
|
||||||
local selected_text = {}
|
local selected_text = {}
|
||||||
for i = start_pos[2], end_pos[2] do
|
for i = start_pos[2], end_pos[2] do
|
||||||
-- 使用 vim.api.nvim_buf_get_lines() 函数获取选中的文本
|
-- 使用 vim.api.nvim_buf_get_lines() 函数获取选中的文本
|
||||||
local line_text = vim.api.nvim_buf_get_lines(0, i - 1, i, false)[1]
|
local line_text = vim.api.nvim_buf_get_lines(0, i - 1, i, false)[1]
|
||||||
|
|
Loading…
Reference in New Issue