Render panel in this test to make sure it can receive focus
This commit is contained in:
parent
cd08d349a5
commit
bbbdb9ff3e
4 changed files with 14 additions and 9 deletions
|
@ -611,7 +611,6 @@ impl AppContext {
|
||||||
.values()
|
.values()
|
||||||
.filter_map(|window| {
|
.filter_map(|window| {
|
||||||
let window = window.as_ref()?;
|
let window = window.as_ref()?;
|
||||||
dbg!(window.focus_invalidated);
|
|
||||||
(window.dirty || window.focus_invalidated).then_some(window.handle)
|
(window.dirty || window.focus_invalidated).then_some(window.handle)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
|
|
@ -470,6 +470,7 @@ impl<'a> WindowContext<'a> {
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
{
|
{
|
||||||
|
println!("invalidating focus");
|
||||||
self.window.focus_invalidated = true;
|
self.window.focus_invalidated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1237,6 +1238,11 @@ impl<'a> WindowContext<'a> {
|
||||||
|
|
||||||
/// Draw pixels to the display for this window based on the contents of its scene.
|
/// Draw pixels to the display for this window based on the contents of its scene.
|
||||||
pub(crate) fn draw(&mut self) -> Scene {
|
pub(crate) fn draw(&mut self) -> Scene {
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
{
|
||||||
|
self.window.focus_invalidated = false;
|
||||||
|
}
|
||||||
|
|
||||||
self.text_system().start_frame();
|
self.text_system().start_frame();
|
||||||
self.window.platform_window.clear_input_handler();
|
self.window.platform_window.clear_input_handler();
|
||||||
self.window.layout_engine.as_mut().unwrap().clear();
|
self.window.layout_engine.as_mut().unwrap().clear();
|
||||||
|
@ -1290,11 +1296,6 @@ impl<'a> WindowContext<'a> {
|
||||||
let current_focus_path = self.window.rendered_frame.focus_path();
|
let current_focus_path = self.window.rendered_frame.focus_path();
|
||||||
|
|
||||||
if previous_focus_path != current_focus_path {
|
if previous_focus_path != current_focus_path {
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
|
||||||
{
|
|
||||||
self.window.focus_invalidated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if !previous_focus_path.is_empty() && current_focus_path.is_empty() {
|
if !previous_focus_path.is_empty() && current_focus_path.is_empty() {
|
||||||
self.window
|
self.window
|
||||||
.blur_listeners
|
.blur_listeners
|
||||||
|
|
|
@ -739,7 +739,6 @@ impl ProjectPanel {
|
||||||
});
|
});
|
||||||
self.filename_editor.update(cx, |editor, cx| {
|
self.filename_editor.update(cx, |editor, cx| {
|
||||||
editor.clear(cx);
|
editor.clear(cx);
|
||||||
println!("focusing");
|
|
||||||
editor.focus(cx);
|
editor.focus(cx);
|
||||||
});
|
});
|
||||||
self.update_visible_entries(Some((worktree_id, NEW_ENTRY_ID)), cx);
|
self.update_visible_entries(Some((worktree_id, NEW_ENTRY_ID)), cx);
|
||||||
|
@ -1672,7 +1671,7 @@ mod tests {
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::atomic::{self, AtomicUsize},
|
sync::atomic::{self, AtomicUsize},
|
||||||
};
|
};
|
||||||
use workspace::AppState;
|
use workspace::{dock::PanelHandle, AppState};
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_visible_list(cx: &mut gpui::TestAppContext) {
|
async fn test_visible_list(cx: &mut gpui::TestAppContext) {
|
||||||
|
@ -2281,7 +2280,12 @@ mod tests {
|
||||||
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
|
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
|
||||||
let cx = &mut VisualTestContext::from_window(*workspace, cx);
|
let cx = &mut VisualTestContext::from_window(*workspace, cx);
|
||||||
let panel = workspace
|
let panel = workspace
|
||||||
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
|
.update(cx, |workspace, cx| {
|
||||||
|
let panel = ProjectPanel::new(workspace, cx);
|
||||||
|
workspace.add_panel(panel.clone(), cx);
|
||||||
|
workspace.toggle_dock(panel.read(cx).position(cx), cx);
|
||||||
|
panel
|
||||||
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
select_path(&panel, "root1", cx);
|
select_path(&panel, "root1", cx);
|
||||||
|
|
|
@ -532,6 +532,7 @@ impl Workspace {
|
||||||
cx.notify()
|
cx.notify()
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
cx.on_blur_window(|this, cx| {
|
cx.on_blur_window(|this, cx| {
|
||||||
let focus_handle = this.focus_handle(cx);
|
let focus_handle = this.focus_handle(cx);
|
||||||
cx.focus(&focus_handle);
|
cx.focus(&focus_handle);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue