diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-11-04 13:46:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 13:46:19 +0100 |
commit | 9d355b8b0d7b9e548096874c696444a20bbb91f2 (patch) | |
tree | 1b2738204184109bebc0244bcc943c157dd37d82 /runtime/lua/vim/treesitter.lua | |
parent | aaaad0f5934460dfaf7ef7a29dcf38060c641b43 (diff) | |
parent | c7d460c197defd2b56b01084b095f6352711b52a (diff) | |
download | rneovim-9d355b8b0d7b9e548096874c696444a20bbb91f2.tar.gz rneovim-9d355b8b0d7b9e548096874c696444a20bbb91f2.tar.bz2 rneovim-9d355b8b0d7b9e548096874c696444a20bbb91f2.zip |
Merge pull request #13219 from vigoux/ts-extract-tree
treesitter: separate tree and parser
Diffstat (limited to 'runtime/lua/vim/treesitter.lua')
-rw-r--r-- | runtime/lua/vim/treesitter.lua | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua index 0de3388356..19ef148afc 100644 --- a/runtime/lua/vim/treesitter.lua +++ b/runtime/lua/vim/treesitter.lua @@ -18,11 +18,13 @@ Parser.__index = Parser -- @returns If the tree changed with this call, the changed ranges function Parser:parse() if self.valid then - return self.tree + return self._tree_immutable end local changes - self.tree, changes = self._parser:parse(self:input_source()) + self._tree, changes = self._parser:parse(self._tree, self:input_source()) + + self._tree_immutable = self._tree:copy() self.valid = true @@ -32,7 +34,7 @@ function Parser:parse() end end - return self.tree, changes + return self._tree_immutable, changes end function Parser:input_source() @@ -45,7 +47,7 @@ function Parser:_on_bytes(bufnr, changed_tick, new_row, new_col, new_byte) local old_end_col = old_col + ((old_row == 0) and start_col or 0) local new_end_col = new_col + ((new_row == 0) and start_col or 0) - self._parser:edit(start_byte,start_byte+old_byte,start_byte+new_byte, + self._tree:edit(start_byte,start_byte+old_byte,start_byte+new_byte, start_row, start_col, start_row+old_row, old_end_col, start_row+new_row, new_end_col) |