diff --git a/src/treesit.c b/src/treesit.c index 93ed97212d7..879405e551a 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -931,7 +931,10 @@ treesit_sync_visible_region (Lisp_Object parser) this function is called), we need to reparse. */ if (visible_beg != BUF_BEGV_BYTE (buffer) || visible_end != BUF_ZV_BYTE (buffer)) - XTS_PARSER (parser)->need_reparse = true; + { + XTS_PARSER (parser)->need_reparse = true; + XTS_PARSER (parser)->timestamp++; + } /* Before we parse or set ranges, catch up with the narrowing situation. We change visible_beg and visible_end to match @@ -1671,6 +1674,7 @@ buffer. */) ranges); XTS_PARSER (parser)->need_reparse = true; + XTS_PARSER (parser)->timestamp++; return Qnil; } diff --git a/src/treesit.h b/src/treesit.h index 5382bc58817..3d59262b53a 100644 --- a/src/treesit.h +++ b/src/treesit.h @@ -53,7 +53,9 @@ struct Lisp_TS_Parser /* Re-parsing an unchanged buffer is not free for tree-sitter, so we only make it re-parse when need_reparse == true. That usually means some change is made in the buffer. But others could set - this field to true to force tree-sitter to re-parse. */ + this field to true to force tree-sitter to re-parse. When you + set this to true, you should _always_ also increment + timestamp. */ bool need_reparse; /* These two positions record the buffer byte position (1-based) of the "visible region" that tree-sitter sees. Before re-parse, we