ref(generator) Prepare generator to use visual selection

This commit is contained in:
danymat
2022-02-14 22:26:14 +01:00
parent d3e0168e1e
commit 218e0a63fd

View File

@@ -191,21 +191,23 @@ return setmetatable({}, {
for r, line in ipairs(template_content) do for r, line in ipairs(template_content) do
local last_col = 0 local last_col = 0
local len = 1 local len = 1
local sects = {}
-- Replace each JUMP_TEXT with an pending text
local insert = string.gsub(line, pattern, "")
table.insert(content, insert)
-- Find each JUMP_TEXT and create a mark for it
while true do while true do
local s, e = line:find(pattern, last_col + 1) local s, e = string.find(line, pattern, last_col + 1)
if not s then if not s then
table.insert(sects, line:sub(last_col + 1, -1))
break break
end end
table.insert(sects, line:sub(last_col + 1, s - 1))
if input_after_comment then if input_after_comment then
len = len + s - last_col - 1 len = len + s - last_col - 1
table.insert(marks_pos, { row + r - 1, len - 1 }) table.insert(marks_pos, { row + r - 1, len - 1 })
end end
last_col = e last_col = e
end end
table.insert(content, table.concat(sects, ""))
end end
-- Append content to row -- Append content to row