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:
@@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user