History

Render panel in this test to make sure it can receive focus

Julia committed 2 years ago

Commit bbbdb9f1 parent cd08d344 files · +14 −9Browse files

Unified · Split

4 files
  1. crates/gpui2/src/app.rs +0 −1
  2. crates/gpui2/src/window.rs +6 −5
  3. crates/project_panel2/src/project_panel.rs +7 −3
  4. crates/workspace2/src/workspace2.rs +1 −0
crates/gpui2/src/app.rs+0−1
@@ -611,7 +611,6 @@ impl AppContext { · 610 unmodified lines
611611 .values()
612612 .filter_map(|window| {
613613 let window = window.as_ref()?;
614− dbg!(window.focus_invalidated);
615614 (window.dirty || window.focus_invalidated).then_some(window.handle)
616615 })
617616 .collect::<Vec<_>>()
crates/gpui2/src/window.rs+6−5
@@ -470,6 +470,7 @@ impl<'a> WindowContext<'a> { · 469 unmodified lines
470470
471471 #[cfg(any(test, feature = "test-support"))]
472472 {
473+ println!("invalidating focus");
473474 self.window.focus_invalidated = true;
474475 }
475476
@@ -1237,6 +1238,11 @@ impl<'a> WindowContext<'a> { · 761 unmodified lines
12371238
12381239 /// Draw pixels to the display for this window based on the contents of its scene.
12391240 pub(crate) fn draw(&mut self) -> Scene {
1241+ #[cfg(any(test, feature = "test-support"))]
1242+ {
1243+ self.window.focus_invalidated = false;
1244+ }
1245+
12401246 self.text_system().start_frame();
12411247 self.window.platform_window.clear_input_handler();
12421248 self.window.layout_engine.as_mut().unwrap().clear();
@@ -1290,11 +1296,6 @@ impl<'a> WindowContext<'a> { · 47 unmodified lines
12901296 let current_focus_path = self.window.rendered_frame.focus_path();
12911297
12921298 if previous_focus_path != current_focus_path {
1293− #[cfg(any(test, feature = "test-support"))]
1294− {
1295− self.window.focus_invalidated = false;
1296− }
1297−
12981299 if !previous_focus_path.is_empty() && current_focus_path.is_empty() {
12991300 self.window
13001301 .blur_listeners
crates/project_panel2/src/project_panel.rs+7−3
@@ -739,7 +739,6 @@ impl ProjectPanel { · 738 unmodified lines
739739 });
740740 self.filename_editor.update(cx, |editor, cx| {
741741 editor.clear(cx);
742− println!("focusing");
743742 editor.focus(cx);
744743 });
745744 self.update_visible_entries(Some((worktree_id, NEW_ENTRY_ID)), cx);
@@ -1672,7 +1671,7 @@ mod tests { · 926 unmodified lines
16721671 path::{Path, PathBuf},
16731672 sync::atomic::{self, AtomicUsize},
16741673 };
1675− use workspace::AppState;
1674+ use workspace::{dock::PanelHandle, AppState};
16761675
16771676 #[gpui::test]
16781677 async fn test_visible_list(cx: &mut gpui::TestAppContext) {
@@ -2281,7 +2280,12 @@ mod tests { · 602 unmodified lines
22812280 let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
22822281 let cx = &mut VisualTestContext::from_window(*workspace, cx);
22832282 let panel = workspace
2284− .update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
2283+ .update(cx, |workspace, cx| {
2284+ let panel = ProjectPanel::new(workspace, cx);
2285+ workspace.add_panel(panel.clone(), cx);
2286+ workspace.toggle_dock(panel.read(cx).position(cx), cx);
2287+ panel
2288+ })
22852289 .unwrap();
22862290
22872291 select_path(&panel, "root1", cx);
crates/workspace2/src/workspace2.rs+1−0
@@ -532,6 +532,7 @@ impl Workspace { · 531 unmodified lines
532532 cx.notify()
533533 })
534534 .detach();
535+
535536 cx.on_blur_window(|this, cx| {
536537 let focus_handle = this.focus_handle(cx);
537538 cx.focus(&focus_handle);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t