mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 06:05:19 +00:00
Transfer focus to root view only if previously-focused view was dropped
This commit is contained in:
parent
185a624b99
commit
4aa2858b2b
1 changed files with 4 additions and 4 deletions
|
@ -1749,11 +1749,11 @@ impl AppContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// When the previously-focused view isn't rendered and
|
// When the previously-focused view has been dropped and
|
||||||
// there isn't any pending focus, focus the root view.
|
// there isn't any pending focus, focus the root view.
|
||||||
let root_view_id = cx.window.root_view().id();
|
let root_view_id = cx.window.root_view().id();
|
||||||
if focused_view_id != root_view_id
|
if focused_view_id != root_view_id
|
||||||
&& !cx.window.parents.contains_key(&focused_view_id)
|
&& !cx.views.contains_key(&(window_id, focused_view_id))
|
||||||
&& !focus_effects.contains_key(&window_id)
|
&& !focus_effects.contains_key(&window_id)
|
||||||
{
|
{
|
||||||
focus_effects.insert(
|
focus_effects.insert(
|
||||||
|
@ -1942,12 +1942,12 @@ impl AppContext {
|
||||||
fn handle_focus_effect(&mut self, effect: FocusEffect) {
|
fn handle_focus_effect(&mut self, effect: FocusEffect) {
|
||||||
let window_id = effect.window_id();
|
let window_id = effect.window_id();
|
||||||
self.update_window(window_id, |cx| {
|
self.update_window(window_id, |cx| {
|
||||||
// Ensure the newly-focused view has been rendered, otherwise focus
|
// Ensure the newly-focused view still exists, otherwise focus
|
||||||
// the root view instead.
|
// the root view instead.
|
||||||
let focused_id = match effect {
|
let focused_id = match effect {
|
||||||
FocusEffect::View { view_id, .. } => {
|
FocusEffect::View { view_id, .. } => {
|
||||||
if let Some(view_id) = view_id {
|
if let Some(view_id) = view_id {
|
||||||
if cx.window.parents.contains_key(&view_id) {
|
if cx.views.contains_key(&(window_id, view_id)) {
|
||||||
Some(view_id)
|
Some(view_id)
|
||||||
} else {
|
} else {
|
||||||
Some(cx.root_view().id())
|
Some(cx.root_view().id())
|
||||||
|
|
Loading…
Reference in a new issue