Fix editor rendering slowness with large folds (#31569)
Closes https://github.com/zed-industries/zed/issues/31565 * Looking up settings on every row was very slow in the case of large folds, especially if there was an `.editorconfig` file with numerous glob patterns * Checking whether each indent guide was within a fold was very slow, when a fold spanned many indent guides. Release Notes: - Fixed slowness that could happen when editing in the presence of large folds.
This commit is contained in:
parent
53849cf983
commit
97579662e6
3 changed files with 137 additions and 38 deletions
|
@ -5753,15 +5753,28 @@ impl MultiBufferSnapshot {
|
|||
let mut result = Vec::new();
|
||||
let mut indent_stack = SmallVec::<[IndentGuide; 8]>::new();
|
||||
|
||||
let mut prev_settings = None;
|
||||
while let Some((first_row, mut line_indent, buffer)) = row_indents.next() {
|
||||
if first_row > end_row {
|
||||
break;
|
||||
}
|
||||
let current_depth = indent_stack.len() as u32;
|
||||
|
||||
let settings =
|
||||
language_settings(buffer.language().map(|l| l.name()), buffer.file(), cx);
|
||||
let tab_size = settings.tab_size.get() as u32;
|
||||
// Avoid retrieving the language settings repeatedly for every buffer row.
|
||||
if let Some((prev_buffer_id, _)) = &prev_settings {
|
||||
if prev_buffer_id != &buffer.remote_id() {
|
||||
prev_settings.take();
|
||||
}
|
||||
}
|
||||
let settings = &prev_settings
|
||||
.get_or_insert_with(|| {
|
||||
(
|
||||
buffer.remote_id(),
|
||||
language_settings(buffer.language().map(|l| l.name()), buffer.file(), cx),
|
||||
)
|
||||
})
|
||||
.1;
|
||||
let tab_size = settings.tab_size.get();
|
||||
|
||||
// When encountering empty, continue until found useful line indent
|
||||
// then add to the indent stack with the depth found
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue