Avoid losing focus when block decorations go offscreen (#14815)

Release Notes:

- Fixed a bug that caused focus to be lost when renames and inline
assists were scrolled offscreen.

---------

Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2024-07-19 17:04:18 +02:00 committed by GitHub
parent f5d50f2b1e
commit d61eaea4b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 941 additions and 584 deletions

View file

@ -261,7 +261,7 @@ pub struct ExcerptRange<T> {
}
#[derive(Clone, Debug, Default)]
struct ExcerptSummary {
pub struct ExcerptSummary {
excerpt_id: ExcerptId,
/// The location of the last [`Excerpt`] being summarized
excerpt_locator: Locator,
@ -3744,6 +3744,21 @@ impl MultiBufferSnapshot {
Some(&self.excerpt(excerpt_id)?.buffer)
}
pub fn range_for_excerpt<'a, T: sum_tree::Dimension<'a, ExcerptSummary>>(
&'a self,
excerpt_id: ExcerptId,
) -> Option<Range<T>> {
let mut cursor = self.excerpts.cursor::<(Option<&Locator>, T)>();
let locator = self.excerpt_locator_for_id(excerpt_id);
if cursor.seek(&Some(locator), Bias::Left, &()) {
let start = cursor.start().1.clone();
let end = cursor.end(&()).1;
Some(start..end)
} else {
None
}
}
fn excerpt(&self, excerpt_id: ExcerptId) -> Option<&Excerpt> {
let mut cursor = self.excerpts.cursor::<Option<&Locator>>();
let locator = self.excerpt_locator_for_id(excerpt_id);