Reduce display_map snapshot creation (#39354)
Re-applies https://github.com/zed-industries/zed/pull/30840 This PR re-applies the initial [PR](https://github.com/zed-industries/zed/pull/30840). As it was closed because it was hard to land, because of the many conflicts. This PR re-applies the changes for it. In several cases we were creating multiple display_map snapshots within the same root-level function call. Creating a display_map snapshot is quite slow, and in some cases we were creating the snapshot multiple times. Release Notes: - N/A
This commit is contained in:
@@ -229,8 +229,11 @@ impl LspLogView {
|
||||
log_view.editor.update(cx, |editor, cx| {
|
||||
editor.set_read_only(false);
|
||||
let last_offset = editor.buffer().read(cx).len(cx);
|
||||
let newest_cursor_is_at_end =
|
||||
editor.selections.newest::<usize>(cx).start >= last_offset;
|
||||
let newest_cursor_is_at_end = editor
|
||||
.selections
|
||||
.newest::<usize>(&editor.display_snapshot(cx))
|
||||
.start
|
||||
>= last_offset;
|
||||
editor.edit(
|
||||
vec![
|
||||
(last_offset..last_offset, text.as_str()),
|
||||
|
||||
@@ -252,7 +252,10 @@ impl SyntaxTreeView {
|
||||
.editor
|
||||
.update(cx, |editor, cx| editor.snapshot(window, cx));
|
||||
let (buffer, range, excerpt_id) = editor_state.editor.update(cx, |editor, cx| {
|
||||
let selection_range = editor.selections.last::<usize>(cx).range();
|
||||
let selection_range = editor
|
||||
.selections
|
||||
.last::<usize>(&editor.display_snapshot(cx))
|
||||
.range();
|
||||
let multi_buffer = editor.buffer().read(cx);
|
||||
let (buffer, range, excerpt_id) = snapshot
|
||||
.buffer_snapshot()
|
||||
|
||||
Reference in New Issue
Block a user