1
0
Fork 0

[Chore] remove unused comments (#15)

feature/custom-highlight-themes
Mist 2024-02-23 23:05:35 +08:00 committed by GitHub
parent 0a8ec5ba97
commit 1a4642657c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 5 deletions

View File

@ -13,22 +13,18 @@ function visual_utils.get_selected_text()
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() 函数获取选中的文本
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]
-- 如果是选中的第一行,需要从 mark 'v' 的列开始获取
if i == start_pos[2] then if i == start_pos[2] then
line_text = line_text:sub(start_pos[3]) line_text = line_text:sub(start_pos[3])
end end
-- 如果是选中的最后一行,需要获取到当前光标的列 -- If select last line, there need to get column of current cursor
if i == end_pos[2] then if i == end_pos[2] then
line_text = line_text:sub(1, end_pos[3] - 1) line_text = line_text:sub(1, end_pos[3] - 1)
end end
table.insert(selected_text, line_text) table.insert(selected_text, line_text)
end end
-- 输出当前选中的文本
return table.concat(selected_text, "\n") return table.concat(selected_text, "\n")
end end
end end