editor: Shrink DisplayMapSnapshot from 824 to 256 bytes (#39568)

We have unnecessary clones for the fields here as most of the snapshots
contain the others hierarchically.

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-06 08:08:49 +00:00
committed by GitHub
parent 9c7369f54d
commit 2bfcd60b88
48 changed files with 594 additions and 543 deletions
@@ -303,8 +303,8 @@ impl EditorLspTestContext {
#[expect(clippy::wrong_self_convention, reason = "This is test code")]
pub fn to_lsp_range(&mut self, range: Range<usize>) -> lsp::Range {
let snapshot = self.update_editor(|editor, window, cx| editor.snapshot(window, cx));
let start_point = range.start.to_point(&snapshot.buffer_snapshot);
let end_point = range.end.to_point(&snapshot.buffer_snapshot);
let start_point = range.start.to_point(&snapshot.buffer_snapshot());
let end_point = range.end.to_point(&snapshot.buffer_snapshot());
self.editor(|editor, _, cx| {
let buffer = editor.buffer().read(cx);
@@ -330,7 +330,7 @@ impl EditorLspTestContext {
#[expect(clippy::wrong_self_convention, reason = "This is test code")]
pub fn to_lsp(&mut self, offset: usize) -> lsp::Position {
let snapshot = self.update_editor(|editor, window, cx| editor.snapshot(window, cx));
let point = offset.to_point(&snapshot.buffer_snapshot);
let point = offset.to_point(&snapshot.buffer_snapshot());
self.editor(|editor, _, cx| {
let buffer = editor.buffer().read(cx);
@@ -504,7 +504,7 @@ impl EditorTestContext {
.map(|h| h.1.clone())
.unwrap_or_default()
.iter()
.map(|range| range.to_offset(&snapshot.buffer_snapshot))
.map(|range| range.to_offset(&snapshot.buffer_snapshot()))
.collect()
});
assert_set_eq!(actual_ranges, expected_ranges);
@@ -519,7 +519,7 @@ impl EditorTestContext {
.map(|ranges| ranges.as_ref().clone().1)
.unwrap_or_default()
.into_iter()
.map(|range| range.to_offset(&snapshot.buffer_snapshot))
.map(|range| range.to_offset(&snapshot.buffer_snapshot()))
.collect();
assert_set_eq!(actual_ranges, expected_ranges);
}
@@ -579,7 +579,7 @@ pub fn assert_state_with_diff(
) {
let (snapshot, selections) = editor.update_in(cx, |editor, window, cx| {
(
editor.snapshot(window, cx).buffer_snapshot.clone(),
editor.snapshot(window, cx).buffer_snapshot().clone(),
editor.selections.ranges::<usize>(cx),
)
});