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:
@@ -278,8 +278,12 @@ impl MarkdownPreviewView {
|
||||
this.parse_markdown_from_active_editor(true, window, cx);
|
||||
}
|
||||
EditorEvent::SelectionsChanged { .. } => {
|
||||
let selection_range = editor
|
||||
.update(cx, |editor, cx| editor.selections.last::<usize>(cx).range());
|
||||
let selection_range = editor.update(cx, |editor, cx| {
|
||||
editor
|
||||
.selections
|
||||
.last::<usize>(&editor.display_snapshot(cx))
|
||||
.range()
|
||||
});
|
||||
this.selected_block = this.get_block_index_under_cursor(selection_range);
|
||||
this.list_state.scroll_to_reveal_item(this.selected_block);
|
||||
cx.notify();
|
||||
|
||||
Reference in New Issue
Block a user