Commit Graph

3 Commits

Author SHA1 Message Date
Lewis Russell
f9a46391ab refactor(treesitter): simplify some range functions 2023-03-06 10:57:14 +00:00
Jaehwang Jung
f0a2ffab29 fix(treesitter): typos in _range.lua
fix(treesitter): typos _range.lua
2023-03-03 11:05:59 +00:00
Lewis Russell
75e53341f3 perf(treesitter): smarter languagetree invalidation
Problem:
  Treesitter injections are slow because all injected trees are invalidated on every change.

Solution:
    Implement smarter invalidation to avoid reparsing injected regions.

    - In on_bytes, try and update self._regions as best we can. This PR just offsets any regions after the change.
    - Add valid flags for each region in self._regions.
    - Call on_bytes recursively for all children.
       - We still need to run the query every time for the top level tree. I don't know how to avoid this. However, if the new injection ranges don't change, then we re-use the old trees and avoid reparsing children.

This should result in roughly a 2-3x reduction in tree parsing when the comment injections are enabled.
2023-02-23 15:19:52 +00:00