fix: preserve diff semantic highlighting across pane focus
This commit is contained in:
@@ -1477,6 +1477,27 @@ impl Editor {
|
||||
.map(|_| focus)
|
||||
}
|
||||
|
||||
pub(crate) fn diff_semantic_tokens(&self, focus: Focus) -> &[SemanticToken] {
|
||||
let Some(diff) = self.diff.as_ref() else {
|
||||
return &[];
|
||||
};
|
||||
let buffer = if focus == Focus::After && diff.after_editable() {
|
||||
diff.live_buffer
|
||||
.and_then(|id| self.buffer(id))
|
||||
.filter(|buffer| Some(buffer.text_revision) == diff.live_revision)
|
||||
} else {
|
||||
let Some(comparison) = diff.comparison_id else {
|
||||
return &[];
|
||||
};
|
||||
std::iter::once(&self.active)
|
||||
.chain(self.parked.values())
|
||||
.find(|buffer| buffer.diff_snapshot == Some((comparison, diff.file, focus)))
|
||||
};
|
||||
buffer
|
||||
.and_then(|buffer| buffer.semantic_tokens.as_deref())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub(crate) fn mutation_blocked(&self) -> bool {
|
||||
self.active.diff_snapshot.is_some() || (self.diff.is_some() && !self.diff_editing())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user