Only debounce the cursor position in multibuffer excerpts (#21946)

Follow up to: https://github.com/zed-industries/zed/pull/20211

Release Notes:

- Improved the performance of the cursor position indicator in single
buffers
This commit is contained in:
Mikayla Maki 2024-12-12 18:27:06 -08:00 committed by GitHub
parent b3de19a6bd
commit 4eaa1c2514
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -48,8 +48,17 @@ impl CursorPosition {
) {
let editor = editor.downgrade();
self.update_position = cx.spawn(|cursor_position, mut cx| async move {
if let Some(debounce) = debounce {
cx.background_executor().timer(debounce).await;
let is_singleton = editor
.update(&mut cx, |editor, cx| {
editor.buffer().read(cx).is_singleton()
})
.ok()
.unwrap_or(true);
if !is_singleton {
if let Some(debounce) = debounce {
cx.background_executor().timer(debounce).await;
}
}
editor