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
611 .values()611 .values()
612 .filter_map(|window| {612 .filter_map(|window| {
613 let window = window.as_ref()?;613 let window = window.as_ref()?;
614 dbg!(window.focus_invalidated);
615 (window.dirty || window.focus_invalidated).then_some(window.handle)614 (window.dirty || window.focus_invalidated).then_some(window.handle)
616 })615 })
617 .collect::<Vec<_>>()616 .collect::<Vec<_>>()
crates/gpui2/src/window.rs+6−5
@@ -470,6 +470,7 @@ impl<'a> WindowContext<'a> { · 469 unmodified lines
470 470
471 #[cfg(any(test, feature = "test-support"))]471 #[cfg(any(test, feature = "test-support"))]
472 {472 {
473 println!("invalidating focus");
473 self.window.focus_invalidated = true;474 self.window.focus_invalidated = true;
474 }475 }
475 476
@@ -1237,6 +1238,11 @@ impl<'a> WindowContext<'a> { · 761 unmodified lines
1237 1238
1238 /// Draw pixels to the display for this window based on the contents of its scene.1239 /// Draw pixels to the display for this window based on the contents of its scene.
1239 pub(crate) fn draw(&mut self) -> Scene {1240 pub(crate) fn draw(&mut self) -> Scene {
1241 #[cfg(any(test, feature = "test-support"))]
1242 {
1243 self.window.focus_invalidated = false;
1244 }
1245
1240 self.text_system().start_frame();1246 self.text_system().start_frame();
1241 self.window.platform_window.clear_input_handler();1247 self.window.platform_window.clear_input_handler();
1242 self.window.layout_engine.as_mut().unwrap().clear();1248 self.window.layout_engine.as_mut().unwrap().clear();
@@ -1290,11 +1296,6 @@ impl<'a> WindowContext<'a> { · 47 unmodified lines
1290 let current_focus_path = self.window.rendered_frame.focus_path();1296 let current_focus_path = self.window.rendered_frame.focus_path();
1291 1297
1292 if previous_focus_path != current_focus_path {1298 if previous_focus_path != current_focus_path {
1293 #[cfg(any(test, feature = "test-support"))]
1294 {
1295 self.window.focus_invalidated = false;
1296 }
1297
1298 if !previous_focus_path.is_empty() && current_focus_path.is_empty() {1299 if !previous_focus_path.is_empty() && current_focus_path.is_empty() {
1299 self.window1300 self.window
1300 .blur_listeners1301 .blur_listeners
crates/project_panel2/src/project_panel.rs+7−3
@@ -739,7 +739,6 @@ impl ProjectPanel { · 738 unmodified lines
739 });739 });
740 self.filename_editor.update(cx, |editor, cx| {740 self.filename_editor.update(cx, |editor, cx| {
741 editor.clear(cx);741 editor.clear(cx);
742 println!("focusing");
743 editor.focus(cx);742 editor.focus(cx);
744 });743 });
745 self.update_visible_entries(Some((worktree_id, NEW_ENTRY_ID)), cx);744 self.update_visible_entries(Some((worktree_id, NEW_ENTRY_ID)), cx);
@@ -1672,7 +1671,7 @@ mod tests { · 926 unmodified lines
1672 path::{Path, PathBuf},1671 path::{Path, PathBuf},
1673 sync::atomic::{self, AtomicUsize},1672 sync::atomic::{self, AtomicUsize},
1674 };1673 };
1675 use workspace::AppState;1674 use workspace::{dock::PanelHandle, AppState};
1676 1675
1677 #[gpui::test]1676 #[gpui::test]
1678 async fn test_visible_list(cx: &mut gpui::TestAppContext) {1677 async fn test_visible_list(cx: &mut gpui::TestAppContext) {
@@ -2281,7 +2280,12 @@ mod tests { · 602 unmodified lines
2281 let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));2280 let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
2282 let cx = &mut VisualTestContext::from_window(*workspace, cx);2281 let cx = &mut VisualTestContext::from_window(*workspace, cx);
2283 let panel = workspace2282 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 })
2285 .unwrap();2289 .unwrap();
2286 2290
2287 select_path(&panel, "root1", cx);2291 select_path(&panel, "root1", cx);
crates/workspace2/src/workspace2.rs+1−0
@@ -532,6 +532,7 @@ impl Workspace { · 531 unmodified lines
532 cx.notify()532 cx.notify()
533 })533 })
534 .detach();534 .detach();
535
535 cx.on_blur_window(|this, cx| {536 cx.on_blur_window(|this, cx| {
536 let focus_handle = this.focus_handle(cx);537 let focus_handle = this.focus_handle(cx);
537 cx.focus(&focus_handle);538 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