Add more menus to Zed (#12940)
### TODO - [x] Make sure keybinding shows up in pane + menu - [x] Selection tool in the editor toolbar - [x] Application Menu - [x] Add more options to pane + menu - Go to File... - Go to Symbol in Project... - [x] Add go items to the selection tool in the editor: - Go to Symbol in Editor... - Go to Line/Column... - Next Problem - Previous Problem - [x] Fix a bug where modals opened from a context menu aren't focused correclty - [x] Determine if or what needs to be done with project actions: - Difficulty is that these are exposed in the UI via clicking the project name in the titlebar or by right clicking the root entry in the project panel. But they require reading and are two clicks away. Is that sufficient? - Add Folder to Project - Open a new project - Open recent - [x] Get a style pass - [x] Implement style pass - [x] Fix the wrong actions in the selection menu - [x] Show selection tool toggle in the 'editor settings' thing - [x] Put preferences section from the app menu onto the right hand user menu - [x] Add Project menu into app menu to replace 'preferences' section, and put the rest of the actions there - [ ] ~~Adopt `...` convention for opening a surface~~ uncertain what this convention is. - [x] Adopt link styling for webview actions - [x] Set lucide hamburger for menu icon - [x] Gate application menu to only show on Linux and Windows Release Notes: - Added a 'selection and movement' tool to the Editor's toolbar, as well as controls to toggle it and a setting to remove it (`"toolbar": {"selections_menu": true/false }`) - Changed the behavior of the `+` menu in the tab bar to use standard actions and keybindings. Replaced 'New Center Terminal' with 'New Terminal', and 'New Search', with the usual 'Deploy Search'. Also added item-creating actions to this menu. - Added an 'application' menu to the titlebar to Linux and Windows builds of Zed
This commit is contained in:
parent
8af8493da6
commit
6b9ddbfef2
33 changed files with 712 additions and 198 deletions
|
@ -7,9 +7,9 @@ use collections::{BTreeSet, HashMap};
|
|||
use editor::{scroll::Autoscroll, Bias, Editor};
|
||||
use fuzzy::{CharBag, PathMatch, PathMatchCandidate};
|
||||
use gpui::{
|
||||
actions, impl_actions, rems, Action, AnyElement, AppContext, DismissEvent, EventEmitter,
|
||||
FocusHandle, FocusableView, Model, Modifiers, ModifiersChangedEvent, ParentElement, Render,
|
||||
Styled, Task, View, ViewContext, VisualContext, WeakView,
|
||||
actions, rems, Action, AnyElement, AppContext, DismissEvent, EventEmitter, FocusHandle,
|
||||
FocusableView, Model, Modifiers, ModifiersChangedEvent, ParentElement, Render, Styled, Task,
|
||||
View, ViewContext, VisualContext, WeakView,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use new_path_prompt::NewPathPrompt;
|
||||
|
@ -30,13 +30,6 @@ use util::{paths::PathLikeWithPosition, post_inc, ResultExt};
|
|||
use workspace::{item::PreviewTabsSettings, ModalView, Workspace};
|
||||
|
||||
actions!(file_finder, [SelectPrev]);
|
||||
impl_actions!(file_finder, [Toggle]);
|
||||
|
||||
#[derive(Default, PartialEq, Eq, Clone, serde::Deserialize)]
|
||||
pub struct Toggle {
|
||||
#[serde(default)]
|
||||
pub separate_history: bool,
|
||||
}
|
||||
|
||||
impl ModalView for FileFinder {}
|
||||
|
||||
|
@ -52,7 +45,7 @@ pub fn init(cx: &mut AppContext) {
|
|||
|
||||
impl FileFinder {
|
||||
fn register(workspace: &mut Workspace, _: &mut ViewContext<Workspace>) {
|
||||
workspace.register_action(|workspace, action: &Toggle, cx| {
|
||||
workspace.register_action(|workspace, action: &workspace::ToggleFileFinder, cx| {
|
||||
let Some(file_finder) = workspace.active_modal::<Self>(cx) else {
|
||||
Self::open(workspace, action.separate_history, cx);
|
||||
return;
|
||||
|
|
|
@ -6,7 +6,7 @@ use gpui::{Entity, TestAppContext, VisualTestContext};
|
|||
use menu::{Confirm, SelectNext, SelectPrev};
|
||||
use project::FS_WATCH_LATENCY;
|
||||
use serde_json::json;
|
||||
use workspace::{AppState, Workspace};
|
||||
use workspace::{AppState, ToggleFileFinder, Workspace};
|
||||
|
||||
#[ctor::ctor]
|
||||
fn init_logger() {
|
||||
|
@ -872,7 +872,7 @@ async fn test_toggle_panel_new_selections(cx: &mut gpui::TestAppContext) {
|
|||
let current_history = open_close_queried_buffer("sec", 1, "second.rs", &workspace, cx).await;
|
||||
|
||||
for expected_selected_index in 0..current_history.len() {
|
||||
cx.dispatch_action(Toggle::default());
|
||||
cx.dispatch_action(ToggleFileFinder::default());
|
||||
let picker = active_file_picker(&workspace, cx);
|
||||
let selected_index = picker.update(cx, |picker, _| picker.delegate.selected_index());
|
||||
assert_eq!(
|
||||
|
@ -881,7 +881,7 @@ async fn test_toggle_panel_new_selections(cx: &mut gpui::TestAppContext) {
|
|||
);
|
||||
}
|
||||
|
||||
cx.dispatch_action(Toggle::default());
|
||||
cx.dispatch_action(ToggleFileFinder::default());
|
||||
let selected_index = workspace.update(cx, |workspace, cx| {
|
||||
workspace
|
||||
.active_modal::<FileFinder>(cx)
|
||||
|
@ -1201,7 +1201,7 @@ async fn test_non_separate_history_items(cx: &mut TestAppContext) {
|
|||
open_close_queried_buffer("lib", 1, "lib.rs", &workspace, cx).await;
|
||||
open_queried_buffer("main", 1, "main.rs", &workspace, cx).await;
|
||||
|
||||
cx.dispatch_action(Toggle::default());
|
||||
cx.dispatch_action(ToggleFileFinder::default());
|
||||
let picker = active_file_picker(&workspace, cx);
|
||||
// main.rs is on top, previously used is selected
|
||||
picker.update(cx, |finder, _| {
|
||||
|
@ -1653,7 +1653,7 @@ async fn test_switches_between_release_norelease_modes_on_forward_nav(
|
|||
// Back to navigation with initial shortcut
|
||||
// Open file on modifiers release
|
||||
cx.simulate_modifiers_change(Modifiers::secondary_key());
|
||||
cx.dispatch_action(Toggle::default());
|
||||
cx.dispatch_action(ToggleFileFinder::default());
|
||||
cx.simulate_modifiers_change(Modifiers::none());
|
||||
cx.read(|cx| {
|
||||
let active_editor = workspace.read(cx).active_item_as::<Editor>(cx).unwrap();
|
||||
|
@ -1769,7 +1769,7 @@ async fn test_repeat_toggle_action(cx: &mut gpui::TestAppContext) {
|
|||
let project = Project::test(app_state.fs.clone(), ["/test".as_ref()], cx).await;
|
||||
let (workspace, cx) = cx.add_window_view(|cx| Workspace::test_new(project, cx));
|
||||
|
||||
cx.dispatch_action(Toggle::default());
|
||||
cx.dispatch_action(ToggleFileFinder::default());
|
||||
let picker = active_file_picker(&workspace, cx);
|
||||
picker.update(cx, |picker, _| {
|
||||
assert_eq!(picker.delegate.selected_index, 0);
|
||||
|
@ -1777,9 +1777,9 @@ async fn test_repeat_toggle_action(cx: &mut gpui::TestAppContext) {
|
|||
});
|
||||
|
||||
// When toggling repeatedly, the picker scrolls to reveal the selected item.
|
||||
cx.dispatch_action(Toggle::default());
|
||||
cx.dispatch_action(Toggle::default());
|
||||
cx.dispatch_action(Toggle::default());
|
||||
cx.dispatch_action(ToggleFileFinder::default());
|
||||
cx.dispatch_action(ToggleFileFinder::default());
|
||||
cx.dispatch_action(ToggleFileFinder::default());
|
||||
picker.update(cx, |picker, _| {
|
||||
assert_eq!(picker.delegate.selected_index, 3);
|
||||
assert_eq!(picker.logical_scroll_top_index(), 3);
|
||||
|
@ -1886,7 +1886,7 @@ fn open_file_picker(
|
|||
workspace: &View<Workspace>,
|
||||
cx: &mut VisualTestContext,
|
||||
) -> View<Picker<FileFinderDelegate>> {
|
||||
cx.dispatch_action(Toggle {
|
||||
cx.dispatch_action(ToggleFileFinder {
|
||||
separate_history: true,
|
||||
});
|
||||
active_file_picker(workspace, cx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue