diff options
author | Christian Clason <c.clason@uni-graz.at> | 2022-02-11 15:19:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-11 15:19:19 +0100 |
commit | 4761dd4fc2d7ecaef3516b3931589e4310bc6db7 (patch) | |
tree | f7bdc2a7fc5c819ad500fbc8b748b1442978ffd2 /runtime/lua/vim/treesitter/query.lua | |
parent | f6329ea137730e571671ee31309ec1b7dc6ec85e (diff) | |
parent | 58d81efcb271b93d2d4903d235eab6c97a6c4d39 (diff) | |
download | rneovim-4761dd4fc2d7ecaef3516b3931589e4310bc6db7.tar.gz rneovim-4761dd4fc2d7ecaef3516b3931589e4310bc6db7.tar.bz2 rneovim-4761dd4fc2d7ecaef3516b3931589e4310bc6db7.zip |
Merge pull request #17365 from kevinhwang91/fix-ts-empty-lines
fix(query.lua): check empty table for lines
Diffstat (limited to 'runtime/lua/vim/treesitter/query.lua')
-rw-r--r-- | runtime/lua/vim/treesitter/query.lua | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua index b3036ea679..14940332d6 100644 --- a/runtime/lua/vim/treesitter/query.lua +++ b/runtime/lua/vim/treesitter/query.lua @@ -199,11 +199,13 @@ function M.get_node_text(node, source) lines = a.nvim_buf_get_lines(source, start_row, end_row + 1, true) end - if #lines == 1 then - lines[1] = string.sub(lines[1], start_col+1, end_col) - else - lines[1] = string.sub(lines[1], start_col+1) - lines[#lines] = string.sub(lines[#lines], 1, end_col) + if #lines > 0 then + if #lines == 1 then + lines[1] = string.sub(lines[1], start_col+1, end_col) + else + lines[1] = string.sub(lines[1], start_col+1) + lines[#lines] = string.sub(lines[#lines], 1, end_col) + end end return table.concat(lines, "\n") |