Fix `ZkNewFromTitleSelection` from a visual block selection (#35)

pull/40/head
Karim Abou Zeid 2 years ago committed by GitHub
parent c3b1bcfe2c
commit b13a191fbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -64,8 +64,9 @@ function M.get_text_in_range(range)
if vim.tbl_isempty(lines) then if vim.tbl_isempty(lines) then
return nil return nil
end end
lines[#lines] = string.sub(lines[#lines], 1, B.character) local MAX_STRING_SUB_INDEX = 2^31 - 1 -- LuaJIT only supports 32bit integers for `string.sub` (in block selection B.character is 2^31)
lines[1] = string.sub(lines[1], A.character + 1) lines[#lines] = string.sub(lines[#lines], 1, math.min(B.character, MAX_STRING_SUB_INDEX))
lines[1] = string.sub(lines[1], math.min(A.character + 1, MAX_STRING_SUB_INDEX))
return table.concat(lines, "\n") return table.concat(lines, "\n")
end end

Loading…
Cancel
Save