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:
@@ -657,7 +657,7 @@ async fn test_editing_files(cx: &mut gpui::TestAppContext) {
|
||||
|
||||
let confirm = panel.update_in(cx, |panel, window, cx| {
|
||||
panel.filename_editor.update(cx, |editor, cx| {
|
||||
let file_name_selections = editor.selections.all::<usize>(cx);
|
||||
let file_name_selections = editor.selections.all::<usize>(&editor.display_snapshot(cx));
|
||||
assert_eq!(
|
||||
file_name_selections.len(),
|
||||
1,
|
||||
@@ -731,7 +731,7 @@ async fn test_editing_files(cx: &mut gpui::TestAppContext) {
|
||||
|
||||
panel.update_in(cx, |panel, window, cx| {
|
||||
panel.filename_editor.update(cx, |editor, cx| {
|
||||
let file_name_selections = editor.selections.all::<usize>(cx);
|
||||
let file_name_selections = editor.selections.all::<usize>(&editor.display_snapshot(cx));
|
||||
assert_eq!(file_name_selections.len(), 1, "File editing should have a single selection, but got: {file_name_selections:?}");
|
||||
let file_name_selection = &file_name_selections[0];
|
||||
assert_eq!(file_name_selection.start, 0, "Should select the file name from the start");
|
||||
@@ -1214,7 +1214,7 @@ async fn test_copy_paste(cx: &mut gpui::TestAppContext) {
|
||||
|
||||
panel.update_in(cx, |panel, window, cx| {
|
||||
panel.filename_editor.update(cx, |editor, cx| {
|
||||
let file_name_selections = editor.selections.all::<usize>(cx);
|
||||
let file_name_selections = editor.selections.all::<usize>(&editor.display_snapshot(cx));
|
||||
assert_eq!(
|
||||
file_name_selections.len(),
|
||||
1,
|
||||
|
||||
Reference in New Issue
Block a user