Always invalidate tree-sitter data on buffer reparse end (#45187) (cherry-pick to stable) (#45189)

zed-zippy[bot] and Kirill Bulatov created

Cherry-pick of #45187 to stable

----
Also do not eagerly invalidate this data on buffer reparse start

Closes https://github.com/zed-industries/zed/issues/45182

Release Notes:

- Fixed bracket colorization not applied on initial file open

Co-authored-by: Kirill Bulatov <kirill@zed.dev>

Change summary

crates/language/src/buffer.rs | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)

Detailed changes

crates/language/src/buffer.rs 🔗

@@ -1670,9 +1670,6 @@ impl Buffer {
     /// for the same buffer, we only initiate a new parse if we are not already
     /// parsing in the background.
     pub fn reparse(&mut self, cx: &mut Context<Self>, may_block: bool) {
-        if self.text.version() != *self.tree_sitter_data.version() {
-            self.invalidate_tree_sitter_data(self.text.snapshot());
-        }
         if self.reparse.is_some() {
             return;
         }
@@ -1774,9 +1771,7 @@ impl Buffer {
         self.syntax_map.lock().did_parse(syntax_snapshot);
         self.request_autoindent(cx);
         self.parse_status.0.send(ParseStatus::Idle).unwrap();
-        if self.text.version() != *self.tree_sitter_data.version() {
-            self.invalidate_tree_sitter_data(self.text.snapshot());
-        }
+        self.invalidate_tree_sitter_data(self.text.snapshot());
         cx.emit(BufferEvent::Reparsed);
         cx.notify();
     }