Clear go-to-def link when deactivating the window
This commit is contained in:
parent
7de8228efd
commit
754a130e59
3 changed files with 55 additions and 13 deletions
|
@ -261,6 +261,7 @@ pub struct AppState {
|
|||
|
||||
pub trait Item: View {
|
||||
fn deactivated(&mut self, _: &mut ViewContext<Self>) {}
|
||||
fn workspace_deactivated(&mut self, _: &mut ViewContext<Self>) {}
|
||||
fn navigate(&mut self, _: Box<dyn Any>, _: &mut ViewContext<Self>) -> bool {
|
||||
false
|
||||
}
|
||||
|
@ -433,6 +434,7 @@ pub trait ItemHandle: 'static + fmt::Debug {
|
|||
cx: &mut ViewContext<Workspace>,
|
||||
);
|
||||
fn deactivated(&self, cx: &mut MutableAppContext);
|
||||
fn workspace_deactivated(&self, cx: &mut MutableAppContext);
|
||||
fn navigate(&self, data: Box<dyn Any>, cx: &mut MutableAppContext) -> bool;
|
||||
fn id(&self) -> usize;
|
||||
fn to_any(&self) -> AnyViewHandle;
|
||||
|
@ -629,6 +631,10 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
|
|||
self.update(cx, |this, cx| this.deactivated(cx));
|
||||
}
|
||||
|
||||
fn workspace_deactivated(&self, cx: &mut MutableAppContext) {
|
||||
self.update(cx, |this, cx| this.workspace_deactivated(cx));
|
||||
}
|
||||
|
||||
fn navigate(&self, data: Box<dyn Any>, cx: &mut MutableAppContext) -> bool {
|
||||
self.update(cx, |this, cx| this.navigate(data, cx))
|
||||
}
|
||||
|
@ -2383,18 +2389,21 @@ impl Workspace {
|
|||
None
|
||||
}
|
||||
|
||||
fn on_window_activation_changed(&mut self, active: bool, cx: &mut ViewContext<Self>) {
|
||||
if !active
|
||||
&& matches!(
|
||||
cx.global::<Settings>().autosave,
|
||||
Autosave::OnWindowChange | Autosave::OnFocusChange
|
||||
)
|
||||
{
|
||||
pub fn on_window_activation_changed(&mut self, active: bool, cx: &mut ViewContext<Self>) {
|
||||
if !active {
|
||||
for pane in &self.panes {
|
||||
pane.update(cx, |pane, cx| {
|
||||
for item in pane.items() {
|
||||
Pane::autosave_item(item.as_ref(), self.project.clone(), cx)
|
||||
.detach_and_log_err(cx);
|
||||
if let Some(item) = pane.active_item() {
|
||||
item.workspace_deactivated(cx);
|
||||
}
|
||||
if matches!(
|
||||
cx.global::<Settings>().autosave,
|
||||
Autosave::OnWindowChange | Autosave::OnFocusChange
|
||||
) {
|
||||
for item in pane.items() {
|
||||
Pane::autosave_item(item.as_ref(), self.project.clone(), cx)
|
||||
.detach_and_log_err(cx);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue