Skip to content

Commit

Permalink
Merge pull request #21 from hangyav/fix/incremental_edits
Browse files Browse the repository at this point in the history
Incremental TS edits
  • Loading branch information
hangyav authored Mar 9, 2024
2 parents 849cca1 + 3d0ecba commit 2aebee3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions textLSP/documents/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ def __len__(self):
class TreeSitterDocument(CleanableDocument):
LIB_PATH_TEMPLATE = '{}/treesitter/{}.so'.format(get_user_cache(), '{}')

# faster persing method is still buggy
CONFIGURATION_REPARSE_ALL = 'reparse_all'
DEFAULT_REPARSE_ALL = True

def __init__(self, language_name, grammar_url, branch, *args, **kwargs):
super().__init__(*args, **kwargs)
#######################################################################
Expand Down Expand Up @@ -862,6 +866,13 @@ def _build_updated_text_intervals(

def _apply_incremental_change(self, change: TextDocumentContentChangeEvent_Type1) -> None:
"""Apply an ``Incremental`` text change to the document"""
reparse_all = self.config.setdefault(
self.CONFIGURATION_REPARSE_ALL,
self.DEFAULT_REPARSE_ALL,
)
if reparse_all:
self._tree = None

if self._tree is None:
super()._apply_incremental_change(change)
return
Expand Down

0 comments on commit 2aebee3

Please sign in to comment.