Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions apps/desktop-gpui/src/screenshot_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,10 @@ impl ScreenshotEditorWindow {
}
})
.detach();
// Every shortcut (Cmd+C included) is a key listener on the root div,
// and with nothing focused gpui dispatches keys to the root view only,
// so the editor ignored the keyboard until something in it was clicked.
window.focus(&this.focus, cx);

this
}
Expand Down Expand Up @@ -5581,6 +5585,32 @@ mod tests {
}
}

#[cfg(target_os = "linux")]
mod open_focus {
use super::*;

#[gpui::test]
fn shortcuts_work_before_the_window_is_clicked(cx: &mut gpui::TestAppContext) {
let project = tempfile::tempdir().unwrap();
let (export_tx, _export_rx) = tokio::sync::mpsc::channel(1);
let (editor, cx) = cx.add_window_view(|window, cx| {
ScreenshotEditorWindow::new(project.path().into(), window, cx)
});
editor.update(cx, |editor, _| editor.export_tx = Some(export_tx));

cx.simulate_keystrokes("p");
editor.read_with(cx, |editor, _| {
assert!(editor.active_popover == Some(Popover::Padding));
});

cx.simulate_keystrokes("cmd-c");
editor.read_with(cx, |editor, _| {
assert!(editor.exporting);
assert!(editor.export_status == ExportStatus::Rendering);
});
}
}

#[cfg(target_os = "linux")]
mod history_interruption {
use super::*;
Expand Down
Loading