keymap: Update Prev
to Previous
for consistency (#25909)
Closes #10167 This is take 2 on https://github.com/zed-industries/zed/pull/2341 which was closed due to lack of migrator. This PR contains rename of following keymap actions: ```sh 1. ["editor::GoToPrevHunk", { "center_cursor": true }] -> ["editor::GoToPreviousHunk", { "center_cursor": true }] 2. "editor::GoToPrevDiagnostic" -> "editor::GoToPreviousDiagnostic" 3. "editor::ContextMenuPrev" -> "editor::ContextMenuPrevious" 4. "search::SelectPrevMatch" -> "search::SelectPreviousMatch" 5. "file_finder::SelectPrev" -> "file_finder::SelectPrevious" 6. "menu::SelectPrev" -> "menu::SelectPrevious" 7. "editor::TabPrev" -> "editor::Backtab" ``` Release Notes: - Renamed several keymap actions for consistency (e.g., `GoToPrevHunk` → `GoToPreviousHunk`, `TabPrev` → `Backtab`). Your existing configured keybindings will still work. You can click **"Backup and Update"** at the top of your keymap file to easily update to the new actions. Co-authored-by: Joseph T. Lyons <JosephTLyons@gmail.com>
This commit is contained in:
parent
61d584db45
commit
593f3dc1d5
43 changed files with 320 additions and 198 deletions
|
@ -33,9 +33,9 @@ impl ThreadHistory {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn select_prev(
|
||||
pub fn select_previous(
|
||||
&mut self,
|
||||
_: &menu::SelectPrev,
|
||||
_: &menu::SelectPrevious,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
|
@ -166,7 +166,7 @@ impl Render for ThreadHistory {
|
|||
.overflow_y_scroll()
|
||||
.size_full()
|
||||
.p_1()
|
||||
.on_action(cx.listener(Self::select_prev))
|
||||
.on_action(cx.listener(Self::select_previous))
|
||||
.on_action(cx.listener(Self::select_next))
|
||||
.on_action(cx.listener(Self::select_first))
|
||||
.on_action(cx.listener(Self::select_last))
|
||||
|
|
|
@ -17,7 +17,7 @@ use gpui::{
|
|||
ListState, MouseDownEvent, ParentElement, Pixels, Point, PromptLevel, Render, SharedString,
|
||||
Styled, Subscription, Task, TextStyle, WeakEntity, Window,
|
||||
};
|
||||
use menu::{Cancel, Confirm, SecondaryConfirm, SelectNext, SelectPrev};
|
||||
use menu::{Cancel, Confirm, SecondaryConfirm, SelectNext, SelectPrevious};
|
||||
use project::{Fs, Project};
|
||||
use rpc::{
|
||||
proto::{self, ChannelVisibility, PeerId},
|
||||
|
@ -1430,7 +1430,7 @@ impl CollabPanel {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
fn select_prev(&mut self, _: &SelectPrev, _: &mut Window, cx: &mut Context<Self>) {
|
||||
fn select_previous(&mut self, _: &SelectPrevious, _: &mut Window, cx: &mut Context<Self>) {
|
||||
let ix = self.selection.take().unwrap_or(0);
|
||||
if ix > 0 {
|
||||
self.selection = Some(ix - 1);
|
||||
|
@ -2878,7 +2878,7 @@ impl Render for CollabPanel {
|
|||
.key_context("CollabPanel")
|
||||
.on_action(cx.listener(CollabPanel::cancel))
|
||||
.on_action(cx.listener(CollabPanel::select_next))
|
||||
.on_action(cx.listener(CollabPanel::select_prev))
|
||||
.on_action(cx.listener(CollabPanel::select_previous))
|
||||
.on_action(cx.listener(CollabPanel::confirm))
|
||||
.on_action(cx.listener(CollabPanel::insert_space))
|
||||
.on_action(cx.listener(CollabPanel::remove_selected_channel))
|
||||
|
|
|
@ -205,7 +205,7 @@ pub struct GoToHunk {
|
|||
|
||||
#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct GoToPrevHunk {
|
||||
pub struct GoToPreviousHunk {
|
||||
#[serde(default)]
|
||||
pub center_cursor: bool,
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ impl_actions!(
|
|||
ExpandExcerptsUp,
|
||||
FoldAt,
|
||||
GoToHunk,
|
||||
GoToPrevHunk,
|
||||
GoToPreviousHunk,
|
||||
HandleInput,
|
||||
MoveDownByLines,
|
||||
MovePageDown,
|
||||
|
@ -281,7 +281,7 @@ gpui::actions!(
|
|||
ContextMenuFirst,
|
||||
ContextMenuLast,
|
||||
ContextMenuNext,
|
||||
ContextMenuPrev,
|
||||
ContextMenuPrevious,
|
||||
ConvertToKebabCase,
|
||||
ConvertToLowerCamelCase,
|
||||
ConvertToLowerCase,
|
||||
|
@ -325,7 +325,7 @@ gpui::actions!(
|
|||
GoToDiagnostic,
|
||||
GoToImplementation,
|
||||
GoToImplementationSplit,
|
||||
GoToPrevDiagnostic,
|
||||
GoToPreviousDiagnostic,
|
||||
GoToTypeDefinition,
|
||||
GoToTypeDefinitionSplit,
|
||||
HalfPageDown,
|
||||
|
@ -420,7 +420,7 @@ gpui::actions!(
|
|||
SplitSelectionIntoLines,
|
||||
SwitchSourceHeader,
|
||||
Tab,
|
||||
TabPrev,
|
||||
Backtab,
|
||||
ToggleAutoSignatureHelp,
|
||||
ToggleGitBlame,
|
||||
ToggleGitBlameInline,
|
||||
|
|
|
@ -7192,7 +7192,7 @@ impl Editor {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn tab_prev(&mut self, _: &TabPrev, window: &mut Window, cx: &mut Context<Self>) {
|
||||
pub fn backtab(&mut self, _: &Backtab, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.move_to_prev_snippet_tabstop(window, cx) {
|
||||
return;
|
||||
}
|
||||
|
@ -9236,7 +9236,7 @@ impl Editor {
|
|||
|
||||
pub fn context_menu_prev(
|
||||
&mut self,
|
||||
_: &ContextMenuPrev,
|
||||
_: &ContextMenuPrevious,
|
||||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
|
@ -11263,7 +11263,7 @@ impl Editor {
|
|||
|
||||
fn go_to_prev_diagnostic(
|
||||
&mut self,
|
||||
_: &GoToPrevDiagnostic,
|
||||
_: &GoToPreviousDiagnostic,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
|
@ -11476,7 +11476,7 @@ impl Editor {
|
|||
|
||||
fn go_to_prev_hunk(
|
||||
&mut self,
|
||||
action: &GoToPrevHunk,
|
||||
action: &GoToPreviousHunk,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
|
|
|
@ -2965,7 +2965,7 @@ async fn test_indent_outdent(cx: &mut TestAppContext) {
|
|||
four
|
||||
"});
|
||||
|
||||
cx.update_editor(|e, window, cx| e.tab_prev(&TabPrev, window, cx));
|
||||
cx.update_editor(|e, window, cx| e.backtab(&Backtab, window, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
«oneˇ» «twoˇ»
|
||||
three
|
||||
|
@ -2985,7 +2985,7 @@ async fn test_indent_outdent(cx: &mut TestAppContext) {
|
|||
ˇ» four
|
||||
"});
|
||||
|
||||
cx.update_editor(|e, window, cx| e.tab_prev(&TabPrev, window, cx));
|
||||
cx.update_editor(|e, window, cx| e.backtab(&Backtab, window, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
one two
|
||||
t«hree
|
||||
|
@ -3010,7 +3010,7 @@ async fn test_indent_outdent(cx: &mut TestAppContext) {
|
|||
ˇ three
|
||||
four
|
||||
"});
|
||||
cx.update_editor(|e, window, cx| e.tab_prev(&TabPrev, window, cx));
|
||||
cx.update_editor(|e, window, cx| e.backtab(&Backtab, window, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
one two
|
||||
ˇthree
|
||||
|
@ -3044,13 +3044,13 @@ async fn test_indent_outdent_with_hard_tabs(cx: &mut TestAppContext) {
|
|||
three
|
||||
four
|
||||
"});
|
||||
cx.update_editor(|e, window, cx| e.tab_prev(&TabPrev, window, cx));
|
||||
cx.update_editor(|e, window, cx| e.backtab(&Backtab, window, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
\t«oneˇ» «twoˇ»
|
||||
three
|
||||
four
|
||||
"});
|
||||
cx.update_editor(|e, window, cx| e.tab_prev(&TabPrev, window, cx));
|
||||
cx.update_editor(|e, window, cx| e.backtab(&Backtab, window, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
«oneˇ» «twoˇ»
|
||||
three
|
||||
|
@ -3075,13 +3075,13 @@ async fn test_indent_outdent_with_hard_tabs(cx: &mut TestAppContext) {
|
|||
\t\tt«hree
|
||||
ˇ»four
|
||||
"});
|
||||
cx.update_editor(|e, window, cx| e.tab_prev(&TabPrev, window, cx));
|
||||
cx.update_editor(|e, window, cx| e.backtab(&Backtab, window, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
one two
|
||||
\tt«hree
|
||||
ˇ»four
|
||||
"});
|
||||
cx.update_editor(|e, window, cx| e.tab_prev(&TabPrev, window, cx));
|
||||
cx.update_editor(|e, window, cx| e.backtab(&Backtab, window, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
one two
|
||||
t«hree
|
||||
|
@ -3094,7 +3094,7 @@ async fn test_indent_outdent_with_hard_tabs(cx: &mut TestAppContext) {
|
|||
ˇthree
|
||||
four
|
||||
"});
|
||||
cx.update_editor(|e, window, cx| e.tab_prev(&TabPrev, window, cx));
|
||||
cx.update_editor(|e, window, cx| e.backtab(&Backtab, window, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
one two
|
||||
ˇthree
|
||||
|
@ -3106,7 +3106,7 @@ async fn test_indent_outdent_with_hard_tabs(cx: &mut TestAppContext) {
|
|||
\tˇthree
|
||||
four
|
||||
"});
|
||||
cx.update_editor(|e, window, cx| e.tab_prev(&TabPrev, window, cx));
|
||||
cx.update_editor(|e, window, cx| e.backtab(&Backtab, window, cx));
|
||||
cx.assert_editor_state(indoc! {"
|
||||
one two
|
||||
ˇthree
|
||||
|
@ -3211,7 +3211,7 @@ fn test_indent_outdent_with_excerpts(cx: &mut TestAppContext) {
|
|||
"},
|
||||
cx,
|
||||
);
|
||||
editor.tab_prev(&TabPrev, window, cx);
|
||||
editor.backtab(&Backtab, window, cx);
|
||||
assert_text_with_selections(
|
||||
&mut editor,
|
||||
indoc! {"
|
||||
|
@ -11026,7 +11026,7 @@ async fn go_to_prev_overlapping_diagnostic(executor: BackgroundExecutor, cx: &mu
|
|||
executor.run_until_parked();
|
||||
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);
|
||||
editor.go_to_prev_diagnostic(&GoToPreviousDiagnostic, window, cx);
|
||||
});
|
||||
|
||||
cx.assert_editor_state(indoc! {"
|
||||
|
@ -11035,7 +11035,7 @@ async fn go_to_prev_overlapping_diagnostic(executor: BackgroundExecutor, cx: &mu
|
|||
"});
|
||||
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);
|
||||
editor.go_to_prev_diagnostic(&GoToPreviousDiagnostic, window, cx);
|
||||
});
|
||||
|
||||
cx.assert_editor_state(indoc! {"
|
||||
|
@ -11044,7 +11044,7 @@ async fn go_to_prev_overlapping_diagnostic(executor: BackgroundExecutor, cx: &mu
|
|||
"});
|
||||
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);
|
||||
editor.go_to_prev_diagnostic(&GoToPreviousDiagnostic, window, cx);
|
||||
});
|
||||
|
||||
cx.assert_editor_state(indoc! {"
|
||||
|
@ -11053,7 +11053,7 @@ async fn go_to_prev_overlapping_diagnostic(executor: BackgroundExecutor, cx: &mu
|
|||
"});
|
||||
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);
|
||||
editor.go_to_prev_diagnostic(&GoToPreviousDiagnostic, window, cx);
|
||||
});
|
||||
|
||||
cx.assert_editor_state(indoc! {"
|
||||
|
@ -11133,7 +11133,7 @@ async fn cycle_through_same_place_diagnostics(
|
|||
|
||||
// Fourth diagnostic
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);
|
||||
editor.go_to_prev_diagnostic(&GoToPreviousDiagnostic, window, cx);
|
||||
});
|
||||
cx.assert_editor_state(indoc! {"
|
||||
fn func(abc def: i32) -> ˇu32 {
|
||||
|
@ -11142,7 +11142,7 @@ async fn cycle_through_same_place_diagnostics(
|
|||
|
||||
// Third diagnostic
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);
|
||||
editor.go_to_prev_diagnostic(&GoToPreviousDiagnostic, window, cx);
|
||||
});
|
||||
cx.assert_editor_state(indoc! {"
|
||||
fn func(abc ˇdef: i32) -> u32 {
|
||||
|
@ -11151,7 +11151,7 @@ async fn cycle_through_same_place_diagnostics(
|
|||
|
||||
// Second diagnostic, same place
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);
|
||||
editor.go_to_prev_diagnostic(&GoToPreviousDiagnostic, window, cx);
|
||||
});
|
||||
cx.assert_editor_state(indoc! {"
|
||||
fn func(abc ˇdef: i32) -> u32 {
|
||||
|
@ -11160,7 +11160,7 @@ async fn cycle_through_same_place_diagnostics(
|
|||
|
||||
// First diagnostic
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);
|
||||
editor.go_to_prev_diagnostic(&GoToPreviousDiagnostic, window, cx);
|
||||
});
|
||||
cx.assert_editor_state(indoc! {"
|
||||
fn func(abcˇ def: i32) -> u32 {
|
||||
|
@ -11169,7 +11169,7 @@ async fn cycle_through_same_place_diagnostics(
|
|||
|
||||
// Wrapped over, fourth diagnostic
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.go_to_prev_diagnostic(&GoToPrevDiagnostic, window, cx);
|
||||
editor.go_to_prev_diagnostic(&GoToPreviousDiagnostic, window, cx);
|
||||
});
|
||||
cx.assert_editor_state(indoc! {"
|
||||
fn func(abc def: i32) -> ˇu32 {
|
||||
|
@ -11435,7 +11435,7 @@ async fn test_go_to_hunk(executor: BackgroundExecutor, cx: &mut TestAppContext)
|
|||
cx.update_editor(|editor, window, cx| {
|
||||
//Wrap around the top of the buffer
|
||||
for _ in 0..2 {
|
||||
editor.go_to_prev_hunk(&GoToPrevHunk::default(), window, cx);
|
||||
editor.go_to_prev_hunk(&GoToPreviousHunk::default(), window, cx);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -11455,7 +11455,7 @@ async fn test_go_to_hunk(executor: BackgroundExecutor, cx: &mut TestAppContext)
|
|||
);
|
||||
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.go_to_prev_hunk(&GoToPrevHunk::default(), window, cx);
|
||||
editor.go_to_prev_hunk(&GoToPreviousHunk::default(), window, cx);
|
||||
});
|
||||
|
||||
cx.assert_editor_state(
|
||||
|
@ -11474,7 +11474,7 @@ async fn test_go_to_hunk(executor: BackgroundExecutor, cx: &mut TestAppContext)
|
|||
);
|
||||
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.go_to_prev_hunk(&GoToPrevHunk::default(), window, cx);
|
||||
editor.go_to_prev_hunk(&GoToPreviousHunk::default(), window, cx);
|
||||
});
|
||||
|
||||
cx.assert_editor_state(
|
||||
|
@ -11494,7 +11494,7 @@ async fn test_go_to_hunk(executor: BackgroundExecutor, cx: &mut TestAppContext)
|
|||
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
for _ in 0..2 {
|
||||
editor.go_to_prev_hunk(&GoToPrevHunk::default(), window, cx);
|
||||
editor.go_to_prev_hunk(&GoToPreviousHunk::default(), window, cx);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -12229,7 +12229,7 @@ async fn test_completions_resolve_happens_once(cx: &mut TestAppContext) {
|
|||
});
|
||||
cx.run_until_parked();
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.context_menu_prev(&ContextMenuPrev, window, cx);
|
||||
editor.context_menu_prev(&ContextMenuPrevious, window, cx);
|
||||
});
|
||||
cx.run_until_parked();
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
|
@ -12419,7 +12419,7 @@ async fn test_completions_default_resolve_data_handling(cx: &mut TestAppContext)
|
|||
resolved_items.lock().clear();
|
||||
|
||||
cx.update_editor(|editor, window, cx| {
|
||||
editor.context_menu_prev(&ContextMenuPrev, window, cx);
|
||||
editor.context_menu_prev(&ContextMenuPrevious, window, cx);
|
||||
});
|
||||
cx.run_until_parked();
|
||||
// Completions that have already been resolved are skipped.
|
||||
|
|
|
@ -19,7 +19,7 @@ use crate::{
|
|||
BlockId, ChunkReplacement, CursorShape, CustomBlockId, DisplayDiffHunk, DisplayPoint,
|
||||
DisplayRow, DocumentHighlightRead, DocumentHighlightWrite, EditDisplayMode, Editor, EditorMode,
|
||||
EditorSettings, EditorSnapshot, EditorStyle, ExpandExcerpts, FocusedBlock, GoToHunk,
|
||||
GoToPrevHunk, GutterDimensions, HalfPageDown, HalfPageUp, HandleInput, HoveredCursor,
|
||||
GoToPreviousHunk, GutterDimensions, HalfPageDown, HalfPageUp, HandleInput, HoveredCursor,
|
||||
InlayHintRefreshReason, InlineCompletion, JumpData, LineDown, LineUp, OpenExcerpts, PageDown,
|
||||
PageUp, Point, RowExt, RowRangeExt, SelectPhase, SelectedTextHighlight, Selection, SoftWrap,
|
||||
StickyHeaderExcerpt, ToPoint, ToggleFold, COLUMNAR_SELECTION_MODIFIERS, CURSORS_VISIBLE_FOR,
|
||||
|
@ -195,7 +195,7 @@ impl EditorElement {
|
|||
register_action(editor, window, Editor::backspace);
|
||||
register_action(editor, window, Editor::delete);
|
||||
register_action(editor, window, Editor::tab);
|
||||
register_action(editor, window, Editor::tab_prev);
|
||||
register_action(editor, window, Editor::backtab);
|
||||
register_action(editor, window, Editor::indent);
|
||||
register_action(editor, window, Editor::outdent);
|
||||
register_action(editor, window, Editor::autoindent);
|
||||
|
@ -8905,7 +8905,7 @@ fn diff_hunk_controls(
|
|||
move |window, cx| {
|
||||
Tooltip::for_action_in(
|
||||
"Previous Hunk",
|
||||
&GoToPrevHunk::default(),
|
||||
&GoToPreviousHunk::default(),
|
||||
&focus_handle,
|
||||
window,
|
||||
cx,
|
||||
|
|
|
@ -44,7 +44,7 @@ use workspace::{
|
|||
Workspace,
|
||||
};
|
||||
|
||||
actions!(file_finder, [SelectPrev, ToggleMenu]);
|
||||
actions!(file_finder, [SelectPrevious, ToggleMenu]);
|
||||
|
||||
impl ModalView for FileFinder {
|
||||
fn on_before_dismiss(
|
||||
|
@ -199,9 +199,14 @@ impl FileFinder {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_select_prev(&mut self, _: &SelectPrev, window: &mut Window, cx: &mut Context<Self>) {
|
||||
fn handle_select_prev(
|
||||
&mut self,
|
||||
_: &SelectPrevious,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.init_modifiers = Some(window.modifiers());
|
||||
window.dispatch_action(Box::new(menu::SelectPrev), cx);
|
||||
window.dispatch_action(Box::new(menu::SelectPrevious), cx);
|
||||
}
|
||||
|
||||
fn handle_toggle_menu(&mut self, _: &ToggleMenu, window: &mut Window, cx: &mut Context<Self>) {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::{assert_eq, future::IntoFuture, path::Path, time::Duration};
|
|||
use super::*;
|
||||
use editor::Editor;
|
||||
use gpui::{Entity, TestAppContext, VisualTestContext};
|
||||
use menu::{Confirm, SelectNext, SelectPrev};
|
||||
use menu::{Confirm, SelectNext, SelectPrevious};
|
||||
use project::{RemoveOptions, FS_WATCH_LATENCY};
|
||||
use serde_json::json;
|
||||
use util::path;
|
||||
|
@ -2059,7 +2059,7 @@ async fn test_switches_between_release_norelease_modes_on_backward_nav(
|
|||
// Switch to navigating with other shortcuts
|
||||
// Don't open file on modifiers release
|
||||
cx.simulate_modifiers_change(Modifiers::control());
|
||||
cx.dispatch_action(menu::SelectPrev);
|
||||
cx.dispatch_action(menu::SelectPrevious);
|
||||
cx.simulate_modifiers_change(Modifiers::none());
|
||||
picker.update(cx, |finder, _| {
|
||||
assert_eq!(finder.delegate.matches.len(), 3);
|
||||
|
@ -2071,7 +2071,7 @@ async fn test_switches_between_release_norelease_modes_on_backward_nav(
|
|||
// Back to navigation with initial shortcut
|
||||
// Open file on modifiers release
|
||||
cx.simulate_modifiers_change(Modifiers::secondary_key());
|
||||
cx.dispatch_action(SelectPrev); // <-- File Finder's SelectPrev, not menu's
|
||||
cx.dispatch_action(SelectPrevious); // <-- File Finder's SelectPrevious, not menu's
|
||||
cx.simulate_modifiers_change(Modifiers::none());
|
||||
cx.read(|cx| {
|
||||
let active_editor = workspace.read(cx).active_item_as::<Editor>(cx).unwrap();
|
||||
|
|
|
@ -21,7 +21,7 @@ use git::{RestoreTrackedFiles, StageAll, TrashUntrackedFiles, UnstageAll};
|
|||
use gpui::*;
|
||||
use itertools::Itertools;
|
||||
use language::{Buffer, File};
|
||||
use menu::{Confirm, SecondaryConfirm, SelectFirst, SelectLast, SelectNext, SelectPrev};
|
||||
use menu::{Confirm, SecondaryConfirm, SelectFirst, SelectLast, SelectNext, SelectPrevious};
|
||||
use multi_buffer::ExcerptInfo;
|
||||
use panel::{
|
||||
panel_editor_container, panel_editor_style, panel_filled_button, panel_icon_button, PanelHeader,
|
||||
|
@ -581,7 +581,12 @@ impl GitPanel {
|
|||
}
|
||||
}
|
||||
|
||||
fn select_prev(&mut self, _: &SelectPrev, _window: &mut Window, cx: &mut Context<Self>) {
|
||||
fn select_previous(
|
||||
&mut self,
|
||||
_: &SelectPrevious,
|
||||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let item_count = self.entries.len();
|
||||
if item_count == 0 {
|
||||
return;
|
||||
|
@ -2596,7 +2601,7 @@ impl Render for GitPanel {
|
|||
})
|
||||
.on_action(cx.listener(Self::select_first))
|
||||
.on_action(cx.listener(Self::select_next))
|
||||
.on_action(cx.listener(Self::select_prev))
|
||||
.on_action(cx.listener(Self::select_previous))
|
||||
.on_action(cx.listener(Self::select_last))
|
||||
.on_action(cx.listener(Self::close_panel))
|
||||
.on_action(cx.listener(Self::open_diff))
|
||||
|
|
|
@ -3,7 +3,7 @@ use anyhow::Result;
|
|||
use buffer_diff::{BufferDiff, DiffHunkSecondaryStatus};
|
||||
use collections::HashSet;
|
||||
use editor::{
|
||||
actions::{GoToHunk, GoToPrevHunk},
|
||||
actions::{GoToHunk, GoToPreviousHunk},
|
||||
scroll::Autoscroll,
|
||||
Editor, EditorEvent, ToPoint,
|
||||
};
|
||||
|
@ -869,7 +869,7 @@ impl Render for ProjectDiffToolbar {
|
|||
.shape(ui::IconButtonShape::Square)
|
||||
.tooltip(Tooltip::for_action_title_in(
|
||||
"Go to previous hunk",
|
||||
&GoToPrevHunk {
|
||||
&GoToPreviousHunk {
|
||||
center_cursor: false,
|
||||
},
|
||||
&focus_handle,
|
||||
|
@ -877,7 +877,7 @@ impl Render for ProjectDiffToolbar {
|
|||
.disabled(!button_states.prev_next)
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.dispatch_action(
|
||||
&GoToPrevHunk {
|
||||
&GoToPreviousHunk {
|
||||
center_cursor: true,
|
||||
},
|
||||
window,
|
||||
|
|
|
@ -15,7 +15,7 @@ actions!(
|
|||
Cancel,
|
||||
Confirm,
|
||||
SecondaryConfirm,
|
||||
SelectPrev,
|
||||
SelectPrevious,
|
||||
SelectNext,
|
||||
SelectFirst,
|
||||
SelectLast,
|
||||
|
|
|
@ -92,6 +92,10 @@ const KEYMAP_MIGRATION_TRANSFORMATION_PATTERNS: MigrationPatterns = &[
|
|||
),
|
||||
(ACTION_STRING_PATTERN, rename_string_action),
|
||||
(CONTEXT_PREDICATE_PATTERN, rename_context_key),
|
||||
(
|
||||
ACTION_STRING_OF_ARRAY_PATTERN,
|
||||
replace_first_string_of_array,
|
||||
),
|
||||
];
|
||||
|
||||
static KEYMAP_MIGRATION_TRANSFORMATION_QUERY: LazyLock<Query> = LazyLock::new(|| {
|
||||
|
@ -265,6 +269,51 @@ static TRANSFORM_ARRAY: LazyLock<HashMap<(&str, &str), &str>> = LazyLock::new(||
|
|||
])
|
||||
});
|
||||
|
||||
const ACTION_STRING_OF_ARRAY_PATTERN: &str = r#"(document
|
||||
(array
|
||||
(object
|
||||
(pair
|
||||
key: (string (string_content) @name)
|
||||
value: (
|
||||
(object
|
||||
(pair
|
||||
key: (string)
|
||||
value: ((array
|
||||
. (string (string_content) @action_name)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(#eq? @name "bindings")
|
||||
)"#;
|
||||
|
||||
// ["editor::GoToPrevHunk", { "center_cursor": true }] -> ["editor::GoToPreviousHunk", { "center_cursor": true }]
|
||||
fn replace_first_string_of_array(
|
||||
contents: &str,
|
||||
mat: &QueryMatch,
|
||||
query: &Query,
|
||||
) -> Option<(Range<usize>, String)> {
|
||||
let action_name_ix = query.capture_index_for_name("action_name")?;
|
||||
let action_name = contents.get(
|
||||
mat.nodes_for_capture_index(action_name_ix)
|
||||
.next()?
|
||||
.byte_range(),
|
||||
)?;
|
||||
let replacement = STRING_OF_ARRAY_REPLACE.get(action_name)?;
|
||||
let range_to_replace = mat
|
||||
.nodes_for_capture_index(action_name_ix)
|
||||
.next()?
|
||||
.byte_range();
|
||||
Some((range_to_replace, replacement.to_string()))
|
||||
}
|
||||
|
||||
static STRING_OF_ARRAY_REPLACE: LazyLock<HashMap<&str, &str>> =
|
||||
LazyLock::new(|| HashMap::from_iter([("editor::GoToPrevHunk", "editor::GoToPreviousHunk")]));
|
||||
|
||||
const ACTION_ARGUMENT_OBJECT_PATTERN: &str = r#"(document
|
||||
(array
|
||||
(object
|
||||
|
@ -424,20 +473,29 @@ static STRING_REPLACE: LazyLock<HashMap<&str, &str>> = LazyLock::new(|| {
|
|||
"editor::ToggleInlineCompletions",
|
||||
"editor::ToggleEditPrediction",
|
||||
),
|
||||
(
|
||||
"editor::GoToPrevDiagnostic",
|
||||
"editor::GoToPreviousDiagnostic",
|
||||
),
|
||||
("editor::ContextMenuPrev", "editor::ContextMenuPrevious"),
|
||||
("search::SelectPrevMatch", "search::SelectPreviousMatch"),
|
||||
("file_finder::SelectPrev", "file_finder::SelectPrevious"),
|
||||
("menu::SelectPrev", "menu::SelectPrevious"),
|
||||
("editor::TabPrev", "editor::Backtab"),
|
||||
])
|
||||
});
|
||||
|
||||
const CONTEXT_PREDICATE_PATTERN: &str = r#"
|
||||
(array
|
||||
(object
|
||||
(pair
|
||||
key: (string (string_content) @name)
|
||||
value: (string (string_content) @context_predicate)
|
||||
const CONTEXT_PREDICATE_PATTERN: &str = r#"(document
|
||||
(array
|
||||
(object
|
||||
(pair
|
||||
key: (string (string_content) @name)
|
||||
value: (string (string_content) @context_predicate)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(#eq? @name "context")
|
||||
"#;
|
||||
(#eq? @name "context")
|
||||
)"#;
|
||||
|
||||
fn rename_context_key(
|
||||
contents: &str,
|
||||
|
@ -940,6 +998,36 @@ mod tests {
|
|||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_string_of_array_replace() {
|
||||
assert_migrate_keymap(
|
||||
r#"
|
||||
[
|
||||
{
|
||||
"bindings": {
|
||||
"ctrl-p": ["editor::GoToPrevHunk", { "center_cursor": true }],
|
||||
"ctrl-q": ["editor::GoToPrevHunk"],
|
||||
"ctrl-q": "editor::GoToPrevHunk", // should remain same
|
||||
}
|
||||
}
|
||||
]
|
||||
"#,
|
||||
Some(
|
||||
r#"
|
||||
[
|
||||
{
|
||||
"bindings": {
|
||||
"ctrl-p": ["editor::GoToPreviousHunk", { "center_cursor": true }],
|
||||
"ctrl-q": ["editor::GoToPreviousHunk"],
|
||||
"ctrl-q": "editor::GoToPrevHunk", // should remain same
|
||||
}
|
||||
}
|
||||
]
|
||||
"#,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_action_argument_snake_case() {
|
||||
// First performs transformations, then replacements
|
||||
|
|
|
@ -448,7 +448,7 @@ mod tests {
|
|||
);
|
||||
assert_single_caret_at_row(&editor, 0, cx);
|
||||
|
||||
cx.dispatch_action(menu::SelectPrev);
|
||||
cx.dispatch_action(menu::SelectPrevious);
|
||||
ensure_outline_view_contents(&outline_view, cx);
|
||||
assert_eq!(
|
||||
highlighted_display_rows(&editor, cx),
|
||||
|
|
|
@ -37,7 +37,7 @@ use gpui::{
|
|||
};
|
||||
use itertools::Itertools;
|
||||
use language::{BufferId, BufferSnapshot, OffsetRangeExt, OutlineItem};
|
||||
use menu::{Cancel, SelectFirst, SelectLast, SelectNext, SelectPrev};
|
||||
use menu::{Cancel, SelectFirst, SelectLast, SelectNext, SelectPrevious};
|
||||
|
||||
use outline_panel_settings::{OutlinePanelDockPosition, OutlinePanelSettings, ShowIndentGuides};
|
||||
use project::{File, Fs, Project, ProjectItem};
|
||||
|
@ -1148,7 +1148,7 @@ impl OutlinePanel {
|
|||
}
|
||||
}
|
||||
|
||||
fn select_prev(&mut self, _: &SelectPrev, window: &mut Window, cx: &mut Context<Self>) {
|
||||
fn select_previous(&mut self, _: &SelectPrevious, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if let Some(entry_to_select) = self.selected_entry().and_then(|selected_entry| {
|
||||
self.cached_entries
|
||||
.iter()
|
||||
|
@ -4911,7 +4911,7 @@ impl Render for OutlinePanel {
|
|||
.on_action(cx.listener(Self::open))
|
||||
.on_action(cx.listener(Self::cancel))
|
||||
.on_action(cx.listener(Self::select_next))
|
||||
.on_action(cx.listener(Self::select_prev))
|
||||
.on_action(cx.listener(Self::select_previous))
|
||||
.on_action(cx.listener(Self::select_first))
|
||||
.on_action(cx.listener(Self::select_last))
|
||||
.on_action(cx.listener(Self::select_parent))
|
||||
|
@ -5851,7 +5851,7 @@ mod tests {
|
|||
});
|
||||
|
||||
outline_panel.update_in(cx, |outline_panel, window, cx| {
|
||||
outline_panel.select_prev(&SelectPrev, window, cx);
|
||||
outline_panel.select_previous(&SelectPrevious, window, cx);
|
||||
outline_panel.open(&Open, window, cx);
|
||||
});
|
||||
cx.executor()
|
||||
|
@ -6138,7 +6138,7 @@ outline: struct OutlineEntryExcerpt <==== selected
|
|||
|
||||
cx.update(|window, cx| {
|
||||
outline_panel.update(cx, |outline_panel, cx| {
|
||||
outline_panel.select_prev(&SelectPrev, window, cx);
|
||||
outline_panel.select_previous(&SelectPrevious, window, cx);
|
||||
});
|
||||
});
|
||||
cx.executor()
|
||||
|
@ -6165,7 +6165,7 @@ outline: struct OutlineEntryExcerpt
|
|||
|
||||
cx.update(|window, cx| {
|
||||
outline_panel.update(cx, |outline_panel, cx| {
|
||||
outline_panel.select_prev(&SelectPrev, window, cx);
|
||||
outline_panel.select_previous(&SelectPrevious, window, cx);
|
||||
});
|
||||
});
|
||||
cx.executor()
|
||||
|
@ -6192,7 +6192,7 @@ outline: struct OutlineEntryExcerpt
|
|||
|
||||
cx.update(|window, cx| {
|
||||
outline_panel.update(cx, |outline_panel, cx| {
|
||||
outline_panel.select_prev(&SelectPrev, window, cx);
|
||||
outline_panel.select_previous(&SelectPrevious, window, cx);
|
||||
});
|
||||
});
|
||||
cx.executor()
|
||||
|
@ -6219,7 +6219,7 @@ outline: struct OutlineEntryExcerpt
|
|||
|
||||
cx.update(|window, cx| {
|
||||
outline_panel.update(cx, |outline_panel, cx| {
|
||||
outline_panel.select_prev(&SelectPrev, window, cx);
|
||||
outline_panel.select_previous(&SelectPrevious, window, cx);
|
||||
});
|
||||
});
|
||||
cx.executor()
|
||||
|
@ -6246,7 +6246,7 @@ outline: struct OutlineEntryExcerpt <==== selected
|
|||
|
||||
cx.update(|window, cx| {
|
||||
outline_panel.update(cx, |outline_panel, cx| {
|
||||
outline_panel.select_prev(&SelectPrev, window, cx);
|
||||
outline_panel.select_previous(&SelectPrevious, window, cx);
|
||||
});
|
||||
});
|
||||
cx.executor()
|
||||
|
|
|
@ -391,7 +391,12 @@ impl<D: PickerDelegate> Picker<D> {
|
|||
}
|
||||
}
|
||||
|
||||
fn select_prev(&mut self, _: &menu::SelectPrev, window: &mut Window, cx: &mut Context<Self>) {
|
||||
fn select_previous(
|
||||
&mut self,
|
||||
_: &menu::SelectPrevious,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let count = self.delegate.match_count();
|
||||
if count > 0 {
|
||||
let index = self.delegate.selected_index();
|
||||
|
@ -786,7 +791,7 @@ impl<D: PickerDelegate> Render for Picker<D> {
|
|||
// We should revisit how the `Picker` is styled to make it more composable.
|
||||
.when(self.is_modal, |this| this.elevation_3(cx))
|
||||
.on_action(cx.listener(Self::select_next))
|
||||
.on_action(cx.listener(Self::select_prev))
|
||||
.on_action(cx.listener(Self::select_previous))
|
||||
.on_action(cx.listener(Self::select_first))
|
||||
.on_action(cx.listener(Self::select_last))
|
||||
.on_action(cx.listener(Self::cancel))
|
||||
|
|
|
@ -26,7 +26,7 @@ use gpui::{
|
|||
};
|
||||
use indexmap::IndexMap;
|
||||
use language::DiagnosticSeverity;
|
||||
use menu::{Confirm, SelectFirst, SelectLast, SelectNext, SelectPrev};
|
||||
use menu::{Confirm, SelectFirst, SelectLast, SelectNext, SelectPrevious};
|
||||
use project::{
|
||||
relativize_path, Entry, EntryKind, Fs, Project, ProjectEntryId, ProjectPath, Worktree,
|
||||
WorktreeId,
|
||||
|
@ -1028,7 +1028,7 @@ impl ProjectPanel {
|
|||
});
|
||||
}
|
||||
|
||||
fn select_prev(&mut self, _: &SelectPrev, window: &mut Window, cx: &mut Context<Self>) {
|
||||
fn select_previous(&mut self, _: &SelectPrevious, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if let Some(edit_state) = &self.edit_state {
|
||||
if edit_state.processing_filename.is_none() {
|
||||
self.filename_editor.update(cx, |editor, cx| {
|
||||
|
@ -4434,7 +4434,7 @@ impl Render for ProjectPanel {
|
|||
}))
|
||||
.key_context(self.dispatch_context(window, cx))
|
||||
.on_action(cx.listener(Self::select_next))
|
||||
.on_action(cx.listener(Self::select_prev))
|
||||
.on_action(cx.listener(Self::select_previous))
|
||||
.on_action(cx.listener(Self::select_first))
|
||||
.on_action(cx.listener(Self::select_last))
|
||||
.on_action(cx.listener(Self::select_parent))
|
||||
|
@ -7522,7 +7522,7 @@ mod tests {
|
|||
);
|
||||
cx.update(|window, cx| {
|
||||
panel.update(cx, |this, cx| {
|
||||
this.select_prev(&Default::default(), window, cx);
|
||||
this.select_previous(&Default::default(), window, cx);
|
||||
})
|
||||
});
|
||||
assert_eq!(
|
||||
|
@ -7579,7 +7579,7 @@ mod tests {
|
|||
// ESC clears out all marks
|
||||
cx.update(|window, cx| {
|
||||
panel.update(cx, |this, cx| {
|
||||
this.select_prev(&SelectPrev, window, cx);
|
||||
this.select_previous(&SelectPrevious, window, cx);
|
||||
this.select_next(&SelectNext, window, cx);
|
||||
})
|
||||
});
|
||||
|
@ -7597,8 +7597,8 @@ mod tests {
|
|||
cx.update(|window, cx| {
|
||||
panel.update(cx, |this, cx| {
|
||||
this.cut(&Cut, window, cx);
|
||||
this.select_prev(&SelectPrev, window, cx);
|
||||
this.select_prev(&SelectPrev, window, cx);
|
||||
this.select_previous(&SelectPrevious, window, cx);
|
||||
this.select_previous(&SelectPrevious, window, cx);
|
||||
|
||||
this.paste(&Paste, window, cx);
|
||||
// this.expand_selected_entry(&ExpandSelectedEntry, cx);
|
||||
|
|
|
@ -245,7 +245,7 @@ impl NotebookEditor {
|
|||
|
||||
pub fn select_previous(
|
||||
&mut self,
|
||||
_: &menu::SelectPrev,
|
||||
_: &menu::SelectPrevious,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
|
|
|
@ -2,14 +2,14 @@ mod registrar;
|
|||
|
||||
use crate::{
|
||||
search_bar::render_nav_button, FocusSearch, NextHistoryQuery, PreviousHistoryQuery, ReplaceAll,
|
||||
ReplaceNext, SearchOptions, SelectAllMatches, SelectNextMatch, SelectPrevMatch,
|
||||
ReplaceNext, SearchOptions, SelectAllMatches, SelectNextMatch, SelectPreviousMatch,
|
||||
ToggleCaseSensitive, ToggleRegex, ToggleReplace, ToggleSelection, ToggleWholeWord,
|
||||
};
|
||||
use any_vec::AnyVec;
|
||||
use anyhow::Context as _;
|
||||
use collections::HashMap;
|
||||
use editor::{
|
||||
actions::{Tab, TabPrev},
|
||||
actions::{Backtab, Tab},
|
||||
DisplayPoint, Editor, EditorElement, EditorSettings, EditorStyle,
|
||||
};
|
||||
use futures::channel::oneshot;
|
||||
|
@ -380,7 +380,7 @@ impl Render for BufferSearchBar {
|
|||
ui::IconName::ChevronLeft,
|
||||
self.active_match_index.is_some(),
|
||||
"Select Previous Match",
|
||||
&SelectPrevMatch,
|
||||
&SelectPreviousMatch,
|
||||
focus_handle.clone(),
|
||||
))
|
||||
.child(render_nav_button(
|
||||
|
@ -477,7 +477,7 @@ impl Render for BufferSearchBar {
|
|||
.track_scroll(&self.scroll_handle)
|
||||
.key_context(key_context)
|
||||
.capture_action(cx.listener(Self::tab))
|
||||
.capture_action(cx.listener(Self::tab_prev))
|
||||
.capture_action(cx.listener(Self::backtab))
|
||||
.on_action(cx.listener(Self::previous_history_query))
|
||||
.on_action(cx.listener(Self::next_history_query))
|
||||
.on_action(cx.listener(Self::dismiss))
|
||||
|
@ -625,13 +625,15 @@ impl BufferSearchBar {
|
|||
this.select_next_match(action, window, cx);
|
||||
}
|
||||
}));
|
||||
registrar.register_handler(WithResults(|this, action: &SelectPrevMatch, window, cx| {
|
||||
if this.supported_options(cx).find_in_results {
|
||||
cx.propagate();
|
||||
} else {
|
||||
this.select_prev_match(action, window, cx);
|
||||
}
|
||||
}));
|
||||
registrar.register_handler(WithResults(
|
||||
|this, action: &SelectPreviousMatch, window, cx| {
|
||||
if this.supported_options(cx).find_in_results {
|
||||
cx.propagate();
|
||||
} else {
|
||||
this.select_prev_match(action, window, cx);
|
||||
}
|
||||
},
|
||||
));
|
||||
registrar.register_handler(WithResults(
|
||||
|this, action: &SelectAllMatches, window, cx| {
|
||||
if this.supported_options(cx).find_in_results {
|
||||
|
@ -996,7 +998,7 @@ impl BufferSearchBar {
|
|||
|
||||
fn select_prev_match(
|
||||
&mut self,
|
||||
_: &SelectPrevMatch,
|
||||
_: &SelectPreviousMatch,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
|
@ -1333,7 +1335,7 @@ impl BufferSearchBar {
|
|||
cx.stop_propagation();
|
||||
}
|
||||
|
||||
fn tab_prev(&mut self, _: &TabPrev, window: &mut Window, cx: &mut Context<Self>) {
|
||||
fn backtab(&mut self, _: &Backtab, window: &mut Window, cx: &mut Context<Self>) {
|
||||
// Search -> Replace -> Search
|
||||
let focus_handle = if self.replace_enabled && self.query_editor_focused {
|
||||
self.replacement_editor.focus_handle(cx)
|
||||
|
@ -1699,7 +1701,7 @@ mod tests {
|
|||
});
|
||||
|
||||
search_bar.update_in(cx, |search_bar, window, cx| {
|
||||
search_bar.select_prev_match(&SelectPrevMatch, window, cx);
|
||||
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
|
||||
assert_eq!(
|
||||
editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
|
||||
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
|
||||
|
@ -1710,7 +1712,7 @@ mod tests {
|
|||
});
|
||||
|
||||
search_bar.update_in(cx, |search_bar, window, cx| {
|
||||
search_bar.select_prev_match(&SelectPrevMatch, window, cx);
|
||||
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
|
||||
assert_eq!(
|
||||
editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
|
||||
[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]
|
||||
|
@ -1721,7 +1723,7 @@ mod tests {
|
|||
});
|
||||
|
||||
search_bar.update_in(cx, |search_bar, window, cx| {
|
||||
search_bar.select_prev_match(&SelectPrevMatch, window, cx);
|
||||
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
|
||||
assert_eq!(
|
||||
editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
|
||||
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
||||
|
@ -1742,7 +1744,7 @@ mod tests {
|
|||
});
|
||||
search_bar.update_in(cx, |search_bar, window, cx| {
|
||||
assert_eq!(search_bar.active_match_index, Some(1));
|
||||
search_bar.select_prev_match(&SelectPrevMatch, window, cx);
|
||||
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
|
||||
assert_eq!(
|
||||
editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
|
||||
[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]
|
||||
|
@ -1784,7 +1786,7 @@ mod tests {
|
|||
});
|
||||
search_bar.update_in(cx, |search_bar, window, cx| {
|
||||
assert_eq!(search_bar.active_match_index, Some(2));
|
||||
search_bar.select_prev_match(&SelectPrevMatch, window, cx);
|
||||
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
|
||||
assert_eq!(
|
||||
editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
|
||||
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
|
||||
|
@ -1826,7 +1828,7 @@ mod tests {
|
|||
});
|
||||
search_bar.update_in(cx, |search_bar, window, cx| {
|
||||
assert_eq!(search_bar.active_match_index, Some(0));
|
||||
search_bar.select_prev_match(&SelectPrevMatch, window, cx);
|
||||
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
|
||||
assert_eq!(
|
||||
editor.update(cx, |editor, cx| editor.selections.display_ranges(cx)),
|
||||
[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]
|
||||
|
@ -2039,7 +2041,7 @@ mod tests {
|
|||
);
|
||||
});
|
||||
search_bar.update(cx, |search_bar, cx| {
|
||||
search_bar.select_prev_match(&SelectPrevMatch, window, cx);
|
||||
search_bar.select_prev_match(&SelectPreviousMatch, window, cx);
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
|
@ -2047,7 +2049,7 @@ mod tests {
|
|||
.update(cx, |_, window, cx| {
|
||||
assert!(
|
||||
editor.read(cx).is_focused(window),
|
||||
"Should still have editor focused after SelectPrevMatch"
|
||||
"Should still have editor focused after SelectPreviousMatch"
|
||||
);
|
||||
|
||||
search_bar.update(cx, |search_bar, cx| {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
buffer_search::Deploy, BufferSearchBar, FocusSearch, NextHistoryQuery, PreviousHistoryQuery,
|
||||
ReplaceAll, ReplaceNext, SearchOptions, SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive,
|
||||
ToggleIncludeIgnored, ToggleRegex, ToggleReplace, ToggleWholeWord,
|
||||
ReplaceAll, ReplaceNext, SearchOptions, SelectNextMatch, SelectPreviousMatch,
|
||||
ToggleCaseSensitive, ToggleIncludeIgnored, ToggleRegex, ToggleReplace, ToggleWholeWord,
|
||||
};
|
||||
use anyhow::Context as _;
|
||||
use collections::{HashMap, HashSet};
|
||||
|
@ -90,7 +90,7 @@ pub fn init(cx: &mut App) {
|
|||
);
|
||||
register_workspace_action(
|
||||
workspace,
|
||||
move |search_bar, action: &SelectPrevMatch, window, cx| {
|
||||
move |search_bar, action: &SelectPreviousMatch, window, cx| {
|
||||
search_bar.select_prev_match(action, window, cx)
|
||||
},
|
||||
);
|
||||
|
@ -1440,9 +1440,9 @@ impl ProjectSearchBar {
|
|||
self.cycle_field(Direction::Next, window, cx);
|
||||
}
|
||||
|
||||
fn tab_previous(
|
||||
fn backtab(
|
||||
&mut self,
|
||||
_: &editor::actions::TabPrev,
|
||||
_: &editor::actions::Backtab,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
|
@ -1697,7 +1697,7 @@ impl ProjectSearchBar {
|
|||
|
||||
fn select_prev_match(
|
||||
&mut self,
|
||||
_: &SelectPrevMatch,
|
||||
_: &SelectPreviousMatch,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
|
@ -1896,7 +1896,7 @@ impl Render for ProjectSearchBar {
|
|||
move |window, cx| {
|
||||
Tooltip::for_action_in(
|
||||
"Go To Previous Match",
|
||||
&SelectPrevMatch,
|
||||
&SelectPreviousMatch,
|
||||
&focus_handle,
|
||||
window,
|
||||
cx,
|
||||
|
@ -2095,7 +2095,7 @@ impl Render for ProjectSearchBar {
|
|||
cx.stop_propagation();
|
||||
}))
|
||||
.capture_action(cx.listener(|this, action, window, cx| {
|
||||
this.tab_previous(action, window, cx);
|
||||
this.backtab(action, window, cx);
|
||||
cx.stop_propagation();
|
||||
}))
|
||||
.on_action(cx.listener(|this, action, window, cx| this.confirm(action, window, cx)))
|
||||
|
|
|
@ -30,7 +30,7 @@ actions!(
|
|||
ToggleReplace,
|
||||
ToggleSelection,
|
||||
SelectNextMatch,
|
||||
SelectPrevMatch,
|
||||
SelectPreviousMatch,
|
||||
SelectAllMatches,
|
||||
NextHistoryQuery,
|
||||
PreviousHistoryQuery,
|
||||
|
|
|
@ -620,7 +620,7 @@ mod tests {
|
|||
// Standard macOS bindings
|
||||
{
|
||||
\"bindings\": {
|
||||
\"up\": \"menu::SelectPrev\",
|
||||
\"up\": \"menu::SelectPrevious\",
|
||||
},
|
||||
},
|
||||
]
|
||||
|
|
|
@ -114,10 +114,10 @@ impl PickerStory {
|
|||
pub fn new(window: &mut Window, cx: &mut App) -> Entity<Self> {
|
||||
cx.new(|cx| {
|
||||
cx.bind_keys([
|
||||
KeyBinding::new("up", menu::SelectPrev, Some("picker")),
|
||||
KeyBinding::new("up", menu::SelectPrevious, Some("picker")),
|
||||
KeyBinding::new("pageup", menu::SelectFirst, Some("picker")),
|
||||
KeyBinding::new("shift-pageup", menu::SelectFirst, Some("picker")),
|
||||
KeyBinding::new("ctrl-p", menu::SelectPrev, Some("picker")),
|
||||
KeyBinding::new("ctrl-p", menu::SelectPrevious, Some("picker")),
|
||||
KeyBinding::new("down", menu::SelectNext, Some("picker")),
|
||||
KeyBinding::new("pagedown", menu::SelectLast, Some("picker")),
|
||||
KeyBinding::new("shift-pagedown", menu::SelectFirst, Some("picker")),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::*;
|
||||
use editor::Editor;
|
||||
use gpui::{TestAppContext, VisualTestContext};
|
||||
use menu::SelectPrev;
|
||||
use menu::SelectPrevious;
|
||||
use project::{Project, ProjectPath};
|
||||
use serde_json::json;
|
||||
use std::path::Path;
|
||||
|
@ -64,7 +64,7 @@ async fn test_open_with_prev_tab_selected_and_cycle_on_toggle_action(
|
|||
assert_match_selection(tab_switcher, 3, tab_1.boxed_clone());
|
||||
});
|
||||
|
||||
cx.dispatch_action(SelectPrev);
|
||||
cx.dispatch_action(SelectPrevious);
|
||||
tab_switcher.update(cx, |tab_switcher, _| {
|
||||
assert_eq!(tab_switcher.delegate.matches.len(), 4);
|
||||
assert_match_at_position(tab_switcher, 0, tab_4.boxed_clone());
|
||||
|
|
|
@ -6,7 +6,7 @@ use gpui::{
|
|||
px, Action, AnyElement, App, AppContext as _, DismissEvent, Entity, EventEmitter, FocusHandle,
|
||||
Focusable, IntoElement, Render, Subscription,
|
||||
};
|
||||
use menu::{SelectFirst, SelectLast, SelectNext, SelectPrev};
|
||||
use menu::{SelectFirst, SelectLast, SelectNext, SelectPrevious};
|
||||
use settings::Settings;
|
||||
use std::{rc::Rc, time::Duration};
|
||||
use theme::ThemeSettings;
|
||||
|
@ -410,7 +410,12 @@ impl ContextMenu {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn select_prev(&mut self, _: &SelectPrev, window: &mut Window, cx: &mut Context<Self>) {
|
||||
pub fn select_previous(
|
||||
&mut self,
|
||||
_: &SelectPrevious,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let Some(ix) = self.selected_index {
|
||||
if ix == 0 {
|
||||
self.handle_select_last(&SelectLast, window, cx);
|
||||
|
@ -555,7 +560,7 @@ impl Render for ContextMenu {
|
|||
.on_action(cx.listener(ContextMenu::select_first))
|
||||
.on_action(cx.listener(ContextMenu::handle_select_last))
|
||||
.on_action(cx.listener(ContextMenu::select_next))
|
||||
.on_action(cx.listener(ContextMenu::select_prev))
|
||||
.on_action(cx.listener(ContextMenu::select_previous))
|
||||
.on_action(cx.listener(ContextMenu::confirm))
|
||||
.on_action(cx.listener(ContextMenu::cancel))
|
||||
.when(!self.delayed, |mut el| {
|
||||
|
|
|
@ -44,7 +44,7 @@ impl Navigable {
|
|||
/// Add a new entry that can be navigated to via keyboard.
|
||||
///
|
||||
/// The order of calls to [Navigable::entry] determines the order of traversal of
|
||||
/// elements via successive uses of `menu:::SelectNext/SelectPrev`
|
||||
/// elements via successive uses of `menu:::SelectNext/SelectPrevious`
|
||||
pub fn entry(mut self, child: NavigableEntry) -> Self {
|
||||
self.selectable_children.push(child);
|
||||
self
|
||||
|
@ -83,7 +83,7 @@ impl RenderOnce for Navigable {
|
|||
})
|
||||
.on_action({
|
||||
let children = self.selectable_children;
|
||||
move |_: &menu::SelectPrev, window, cx| {
|
||||
move |_: &menu::SelectPrevious, window, cx| {
|
||||
let target = Self::find_focused(&children, window, cx)
|
||||
.and_then(|index| index.checked_sub(1))
|
||||
.or(children.len().checked_sub(1));
|
||||
|
|
|
@ -827,10 +827,12 @@ fn generate_commands(_: &App) -> Vec<VimCommand> {
|
|||
VimCommand::new(("cc", ""), editor::actions::Hover),
|
||||
VimCommand::new(("ll", ""), editor::actions::Hover),
|
||||
VimCommand::new(("cn", "ext"), editor::actions::GoToDiagnostic).range(wrap_count),
|
||||
VimCommand::new(("cp", "revious"), editor::actions::GoToPrevDiagnostic).range(wrap_count),
|
||||
VimCommand::new(("cN", "ext"), editor::actions::GoToPrevDiagnostic).range(wrap_count),
|
||||
VimCommand::new(("lp", "revious"), editor::actions::GoToPrevDiagnostic).range(wrap_count),
|
||||
VimCommand::new(("lN", "ext"), editor::actions::GoToPrevDiagnostic).range(wrap_count),
|
||||
VimCommand::new(("cp", "revious"), editor::actions::GoToPreviousDiagnostic)
|
||||
.range(wrap_count),
|
||||
VimCommand::new(("cN", "ext"), editor::actions::GoToPreviousDiagnostic).range(wrap_count),
|
||||
VimCommand::new(("lp", "revious"), editor::actions::GoToPreviousDiagnostic)
|
||||
.range(wrap_count),
|
||||
VimCommand::new(("lN", "ext"), editor::actions::GoToPreviousDiagnostic).range(wrap_count),
|
||||
VimCommand::new(("j", "oin"), JoinLines).range(select_range),
|
||||
VimCommand::new(("fo", "ld"), editor::actions::FoldSelectedRanges).range(act_on_range),
|
||||
VimCommand::new(("foldo", "pen"), editor::actions::UnfoldLines)
|
||||
|
|
|
@ -189,7 +189,7 @@ pub fn app_menus() -> Vec<Menu> {
|
|||
MenuItem::action("Find All References", editor::actions::FindAllReferences),
|
||||
MenuItem::separator(),
|
||||
MenuItem::action("Next Problem", editor::actions::GoToDiagnostic),
|
||||
MenuItem::action("Previous Problem", editor::actions::GoToPrevDiagnostic),
|
||||
MenuItem::action("Previous Problem", editor::actions::GoToPreviousDiagnostic),
|
||||
],
|
||||
},
|
||||
Menu {
|
||||
|
|
|
@ -102,7 +102,12 @@ impl FallbackPromptRenderer {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
fn select_prev(&mut self, _: &menu::SelectPrev, _window: &mut Window, cx: &mut Context<Self>) {
|
||||
fn select_previous(
|
||||
&mut self,
|
||||
_: &menu::SelectPrevious,
|
||||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.active_action_id = (self.active_action_id + 1) % self.actions.len();
|
||||
cx.notify();
|
||||
}
|
||||
|
@ -119,7 +124,7 @@ impl Render for FallbackPromptRenderer {
|
|||
.on_action(cx.listener(Self::confirm))
|
||||
.on_action(cx.listener(Self::cancel))
|
||||
.on_action(cx.listener(Self::select_next))
|
||||
.on_action(cx.listener(Self::select_prev))
|
||||
.on_action(cx.listener(Self::select_previous))
|
||||
.on_action(cx.listener(Self::select_first))
|
||||
.on_action(cx.listener(Self::select_last))
|
||||
.elevation_3(cx)
|
||||
|
|
|
@ -5,8 +5,8 @@ use assistant::AssistantPanel;
|
|||
use assistant_settings::AssistantSettings;
|
||||
use editor::actions::{
|
||||
AddSelectionAbove, AddSelectionBelow, DuplicateLineDown, GoToDiagnostic, GoToHunk,
|
||||
GoToPrevDiagnostic, GoToPrevHunk, MoveLineDown, MoveLineUp, SelectAll, SelectLargerSyntaxNode,
|
||||
SelectNext, SelectSmallerSyntaxNode, ToggleGoToLine,
|
||||
GoToPreviousDiagnostic, GoToPreviousHunk, MoveLineDown, MoveLineUp, SelectAll,
|
||||
SelectLargerSyntaxNode, SelectNext, SelectSmallerSyntaxNode, ToggleGoToLine,
|
||||
};
|
||||
use editor::{Editor, EditorSettings};
|
||||
use gpui::{
|
||||
|
@ -180,7 +180,7 @@ impl Render for QuickActionBar {
|
|||
.action("Go to Line/Column", Box::new(ToggleGoToLine))
|
||||
.separator()
|
||||
.action("Next Problem", Box::new(GoToDiagnostic))
|
||||
.action("Previous Problem", Box::new(GoToPrevDiagnostic))
|
||||
.action("Previous Problem", Box::new(GoToPreviousDiagnostic))
|
||||
.separator()
|
||||
.action(
|
||||
"Next Hunk",
|
||||
|
@ -190,7 +190,7 @@ impl Render for QuickActionBar {
|
|||
)
|
||||
.action(
|
||||
"Previous Hunk",
|
||||
Box::new(GoToPrevHunk {
|
||||
Box::new(GoToPreviousHunk {
|
||||
center_cursor: true,
|
||||
}),
|
||||
)
|
||||
|
|
|
@ -82,7 +82,12 @@ impl RateCompletionModal {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
fn select_prev(&mut self, _: &menu::SelectPrev, _: &mut Window, cx: &mut Context<Self>) {
|
||||
fn select_previous(
|
||||
&mut self,
|
||||
_: &menu::SelectPrevious,
|
||||
_: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.selected_index = self.selected_index.saturating_sub(1);
|
||||
cx.notify();
|
||||
}
|
||||
|
@ -529,7 +534,7 @@ impl Render for RateCompletionModal {
|
|||
.track_focus(&self.focus_handle)
|
||||
.on_action(cx.listener(Self::dismiss))
|
||||
.on_action(cx.listener(Self::confirm))
|
||||
.on_action(cx.listener(Self::select_prev))
|
||||
.on_action(cx.listener(Self::select_previous))
|
||||
.on_action(cx.listener(Self::select_prev_edit))
|
||||
.on_action(cx.listener(Self::select_next))
|
||||
.on_action(cx.listener(Self::select_next_edit))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue