diff options
author | Simon Hauser <Simon-Hauser@outlook.de> | 2021-02-24 03:39:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-23 21:39:35 -0500 |
commit | 6b7cc45c4845624aa08232a860941b5a55b9640b (patch) | |
tree | 7710239e424754c43c442fbaf3bf1083ae8cf958 | |
parent | 0450e155d48cb2d8a73358e193931d8966a9d2e0 (diff) | |
download | rneovim-6b7cc45c4845624aa08232a860941b5a55b9640b.tar.gz rneovim-6b7cc45c4845624aa08232a860941b5a55b9640b.tar.bz2 rneovim-6b7cc45c4845624aa08232a860941b5a55b9640b.zip |
fix: treesitter languagetree crash when using telescope buffer previewer (#13986)
-rw-r--r-- | runtime/lua/vim/treesitter/languagetree.lua | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua index 28a87f26c7..4168c1e365 100644 --- a/runtime/lua/vim/treesitter/languagetree.lua +++ b/runtime/lua/vim/treesitter/languagetree.lua @@ -249,17 +249,17 @@ end -- -- @param regions A list of regions this tree should manage and parse. function LanguageTree:set_included_regions(regions) - -- Transform the tables from 4 element long to 6 element long (with byte offset) - for _, region in ipairs(regions) do - for i, range in ipairs(region) do - if type(range) == "table" and #range == 4 then - -- TODO(vigoux): I don't think string parsers are useful for now - if type(self._source) == "number" then + -- TODO(vigoux): I don't think string parsers are useful for now + if type(self._source) == "number" then + -- Transform the tables from 4 element long to 6 element long (with byte offset) + for _, region in ipairs(regions) do + for i, range in ipairs(region) do + if type(range) == "table" and #range == 4 then local start_row, start_col, end_row, end_col = unpack(range) -- Easy case, this is a buffer parser -- TODO(vigoux): proper byte computation here, and account for EOL ? - local start_byte = a.nvim_buf_get_offset(self.bufnr, start_row) + start_col - local end_byte = a.nvim_buf_get_offset(self.bufnr, end_row) + end_col + local start_byte = a.nvim_buf_get_offset(self._source, start_row) + start_col + local end_byte = a.nvim_buf_get_offset(self._source, end_row) + end_col region[i] = { start_row, start_col, start_byte, end_row, end_col, end_byte } end |