editor: Re-use multibuffers when opening the same locations again (#37994)

A very primitive attempt, we just key the editor with the locations and
re-use the editor if we open a new buffer with the same initial
locations and title.

Release Notes:

- Added reusing of reference search buffers when applicable
This commit is contained in:
Lukas Wirth
2025-09-11 16:58:11 +02:00
committed by GitHub
parent e5c0373011
commit 462293667b
4 changed files with 218 additions and 49 deletions
+8 -11
View File
@@ -2092,17 +2092,14 @@ impl MultiBuffer {
let snapshot = self.read(cx);
let buffers = self.buffers.borrow();
let mut cursor = snapshot.excerpts.cursor::<Option<&Locator>>(&());
for locator in buffers
.get(&buffer_id)
.map(|state| &state.excerpts)
.into_iter()
.flatten()
{
cursor.seek_forward(&Some(locator), Bias::Left);
if let Some(excerpt) = cursor.item()
&& excerpt.locator == *locator
{
excerpts.push((excerpt.id, excerpt.range.clone()));
if let Some(locators) = buffers.get(&buffer_id).map(|state| &state.excerpts) {
for locator in locators {
cursor.seek_forward(&Some(locator), Bias::Left);
if let Some(excerpt) = cursor.item()
&& excerpt.locator == *locator
{
excerpts.push((excerpt.id, excerpt.range.clone()));
}
}
}