Skip over folded regions when iterating over multibuffer chunks (#15646)

This commit weaves through new APIs for language::BufferChunks, multi_buffer::MultiBufferChunks and inlay_map::InlayChunks that allow seeking with an upper-bound. This allows us to omit doing syntax highligting and looking up diagnostics for folded ranges. This in turn directly improves performance of assistant panel with large contexts.

Release Notes:

- Fixed poor performance when editing in the assistant panel after
inserting large files using slash commands

---------

Co-authored-by: Max <max@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Piotr Osiewicz 2024-08-02 19:51:26 +02:00 committed by GitHub
parent 390815dd76
commit ad11d83724
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 261 additions and 106 deletions

View file

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