language: Do not fetch diagnostics when iterating over text without language awareness (#16824)

This PR fixes a regression from
https://github.com/zed-industries/zed/pull/15646 where we've started
fetching diagnostic spans unconditionally (whereas previously that
wasn't done when iterating over raw text).

Closes #16764

Release Notes:

- Fixed performance regression in handling buffers with large quantities
of diagnostics.
This commit is contained in:
Piotr Osiewicz 2024-08-25 18:02:54 +02:00 committed by GitHub
parent 14f8d3a33a
commit 5e55d5507f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 40 additions and 30 deletions

View file

@ -1358,7 +1358,9 @@ impl Language {
});
let highlight_maps = vec![grammar.highlight_map()];
let mut offset = 0;
for chunk in BufferChunks::new(text, range, Some((captures, highlight_maps)), None) {
for chunk in
BufferChunks::new(text, range, Some((captures, highlight_maps)), false, None)
{
let end_offset = offset + chunk.text.len();
if let Some(highlight_id) = chunk.syntax_highlight_id {
if !highlight_id.is_default() {