diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index 241b9af923..20d5efaaa8 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -19,12 +19,13 @@ use chrono::{DateTime, Local}; use client::telemetry::AssistantKind; use collections::{hash_map, HashMap, HashSet, VecDeque}; use editor::{ + actions::{MoveDown, MoveUp}, display_map::{ BlockContext, BlockDisposition, BlockId, BlockProperties, BlockStyle, ToDisplayPoint, }, - scroll::autoscroll::{Autoscroll, AutoscrollStrategy}, - Anchor, Editor, EditorElement, EditorEvent, EditorStyle, MoveDown, MoveUp, MultiBufferSnapshot, - ToOffset, ToPoint, + scroll::{Autoscroll, AutoscrollStrategy}, + Anchor, Editor, EditorElement, EditorEvent, EditorStyle, MultiBufferSnapshot, ToOffset, + ToPoint, }; use fs::Fs; use futures::StreamExt; @@ -479,7 +480,7 @@ impl AssistantPanel { fn cancel_last_inline_assist( workspace: &mut Workspace, - _: &editor::Cancel, + _: &editor::actions::Cancel, cx: &mut ViewContext, ) { if let Some(panel) = workspace.panel::(cx) { @@ -891,7 +892,7 @@ impl AssistantPanel { } } - fn handle_editor_cancel(&mut self, _: &editor::Cancel, cx: &mut ViewContext) { + fn handle_editor_cancel(&mut self, _: &editor::actions::Cancel, cx: &mut ViewContext) { if let Some(search_bar) = self.toolbar.read(cx).item_of_type::() { if !search_bar.read(cx).is_dismissed() { search_bar.update(cx, |search_bar, cx| { @@ -2158,7 +2159,7 @@ impl ConversationEditor { } } - fn cancel_last_assist(&mut self, _: &editor::Cancel, cx: &mut ViewContext) { + fn cancel_last_assist(&mut self, _: &editor::actions::Cancel, cx: &mut ViewContext) { if !self .conversation .update(cx, |conversation, _| conversation.cancel_last_assist()) @@ -2417,7 +2418,7 @@ impl ConversationEditor { } } - fn copy(&mut self, _: &editor::Copy, cx: &mut ViewContext) { + fn copy(&mut self, _: &editor::actions::Copy, cx: &mut ViewContext) { let editor = self.editor.read(cx); let conversation = self.conversation.read(cx); if editor.selections.count() == 1 { @@ -2828,7 +2829,7 @@ impl InlineAssistant { cx.notify(); } - fn cancel(&mut self, _: &editor::Cancel, cx: &mut ViewContext) { + fn cancel(&mut self, _: &editor::actions::Cancel, cx: &mut ViewContext) { cx.emit(InlineAssistantEvent::Canceled); } diff --git a/crates/collab/src/tests/editor_tests.rs b/crates/collab/src/tests/editor_tests.rs index a5fa187d24..6f1ad6e4a3 100644 --- a/crates/collab/src/tests/editor_tests.rs +++ b/crates/collab/src/tests/editor_tests.rs @@ -8,9 +8,11 @@ use std::{ use call::ActiveCall; use editor::{ + actions::{ + ConfirmCodeAction, ConfirmCompletion, ConfirmRename, Redo, Rename, ToggleCodeActions, Undo, + }, test::editor_test_context::{AssertionContextManager, EditorTestContext}, - ConfirmCodeAction, ConfirmCompletion, ConfirmRename, Editor, Redo, Rename, ToggleCodeActions, - Undo, + Editor, }; use futures::StreamExt; use gpui::{TestAppContext, VisualContext, VisualTestContext}; @@ -217,7 +219,8 @@ async fn test_newline_above_or_below_does_not_move_guest_cursor( editor_cx_b.set_selections_state(indoc! {" Some textˇ "}); - editor_cx_a.update_editor(|editor, cx| editor.newline_above(&editor::NewlineAbove, cx)); + editor_cx_a + .update_editor(|editor, cx| editor.newline_above(&editor::actions::NewlineAbove, cx)); executor.run_until_parked(); editor_cx_a.assert_editor_state(indoc! {" ˇ @@ -237,7 +240,8 @@ async fn test_newline_above_or_below_does_not_move_guest_cursor( Some textˇ "}); - editor_cx_a.update_editor(|editor, cx| editor.newline_below(&editor::NewlineBelow, cx)); + editor_cx_a + .update_editor(|editor, cx| editor.newline_below(&editor::actions::NewlineBelow, cx)); executor.run_until_parked(); editor_cx_a.assert_editor_state(indoc! {" diff --git a/crates/collab/src/tests/following_tests.rs b/crates/collab/src/tests/following_tests.rs index af184d7d02..d3565eb7ca 100644 --- a/crates/collab/src/tests/following_tests.rs +++ b/crates/collab/src/tests/following_tests.rs @@ -1229,7 +1229,9 @@ async fn test_auto_unfollowing(cx_a: &mut TestAppContext, cx_b: &mut TestAppCont }); // When client B moves, it automatically stops following client A. - editor_b2.update(cx_b, |editor, cx| editor.move_right(&editor::MoveRight, cx)); + editor_b2.update(cx_b, |editor, cx| { + editor.move_right(&editor::actions::MoveRight, cx) + }); assert_eq!( workspace_b.update(cx_b, |workspace, _| workspace.leader_for_pane(&pane_b)), None diff --git a/crates/copilot_ui/src/copilot_button.rs b/crates/copilot_ui/src/copilot_button.rs index e5a1a94235..9dc4e75cb1 100644 --- a/crates/copilot_ui/src/copilot_button.rs +++ b/crates/copilot_ui/src/copilot_button.rs @@ -1,7 +1,7 @@ use crate::sign_in::CopilotCodeVerification; use anyhow::Result; use copilot::{Copilot, SignOut, Status}; -use editor::{scroll::autoscroll::Autoscroll, Editor}; +use editor::{scroll::Autoscroll, Editor}; use fs::Fs; use gpui::{ div, Action, AnchorCorner, AppContext, AsyncWindowContext, Entity, IntoElement, ParentElement, diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index ca701e626e..8504d3de5e 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -8,7 +8,7 @@ use editor::{ diagnostic_block_renderer, display_map::{BlockDisposition, BlockId, BlockProperties, BlockStyle, RenderBlock}, highlight_diagnostic_message, - scroll::autoscroll::Autoscroll, + scroll::Autoscroll, Editor, EditorEvent, ExcerptId, ExcerptRange, MultiBuffer, ToOffset, }; use futures::future::try_join_all; diff --git a/crates/diagnostics/src/items.rs b/crates/diagnostics/src/items.rs index 462718c0f3..d823ad52af 100644 --- a/crates/diagnostics/src/items.rs +++ b/crates/diagnostics/src/items.rs @@ -80,7 +80,7 @@ impl Render for DiagnosticIndicator { Button::new("diagnostic_message", message) .label_size(LabelSize::Small) .tooltip(|cx| { - Tooltip::for_action("Next Diagnostic", &editor::GoToDiagnostic, cx) + Tooltip::for_action("Next Diagnostic", &editor::actions::GoToDiagnostic, cx) }) .on_click(cx.listener(|this, _, cx| { this.go_to_next_diagnostic(cx); diff --git a/crates/editor/src/actions.rs b/crates/editor/src/actions.rs new file mode 100644 index 0000000000..9532bb642d --- /dev/null +++ b/crates/editor/src/actions.rs @@ -0,0 +1,218 @@ +//! This module contains all actions supported by [`Editor`]. +use super::*; + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct SelectNext { + #[serde(default)] + pub replace_newest: bool, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct SelectPrevious { + #[serde(default)] + pub replace_newest: bool, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct SelectAllMatches { + #[serde(default)] + pub replace_newest: bool, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct SelectToBeginningOfLine { + #[serde(default)] + pub(super) stop_at_soft_wraps: bool, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct MovePageUp { + #[serde(default)] + pub(super) center_cursor: bool, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct MovePageDown { + #[serde(default)] + pub(super) center_cursor: bool, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct SelectToEndOfLine { + #[serde(default)] + pub(super) stop_at_soft_wraps: bool, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct ToggleCodeActions { + #[serde(default)] + pub deployed_from_indicator: bool, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct ConfirmCompletion { + #[serde(default)] + pub item_ix: Option, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct ConfirmCodeAction { + #[serde(default)] + pub item_ix: Option, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct ToggleComments { + #[serde(default)] + pub advance_downwards: bool, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct FoldAt { + pub buffer_row: u32, +} + +#[derive(PartialEq, Clone, Deserialize, Default)] +pub struct UnfoldAt { + pub buffer_row: u32, +} +impl_actions!( + editor, + [ + SelectNext, + SelectPrevious, + SelectAllMatches, + SelectToBeginningOfLine, + MovePageUp, + MovePageDown, + SelectToEndOfLine, + ToggleCodeActions, + ConfirmCompletion, + ConfirmCodeAction, + ToggleComments, + FoldAt, + UnfoldAt + ] +); + +gpui::actions!( + editor, + [ + AddSelectionAbove, + AddSelectionBelow, + Backspace, + Cancel, + ConfirmRename, + ContextMenuFirst, + ContextMenuLast, + ContextMenuNext, + ContextMenuPrev, + ConvertToKebabCase, + ConvertToLowerCamelCase, + ConvertToLowerCase, + ConvertToSnakeCase, + ConvertToTitleCase, + ConvertToUpperCamelCase, + ConvertToUpperCase, + Copy, + CopyHighlightJson, + CopyPath, + CopyRelativePath, + Cut, + CutToEndOfLine, + Delete, + DeleteLine, + DeleteToBeginningOfLine, + DeleteToEndOfLine, + DeleteToNextSubwordEnd, + DeleteToNextWordEnd, + DeleteToPreviousSubwordStart, + DeleteToPreviousWordStart, + DuplicateLine, + ExpandMacroRecursively, + FindAllReferences, + Fold, + FoldSelectedRanges, + Format, + GoToDefinition, + GoToDefinitionSplit, + GoToDiagnostic, + GoToHunk, + GoToPrevDiagnostic, + GoToPrevHunk, + GoToTypeDefinition, + GoToTypeDefinitionSplit, + HalfPageDown, + HalfPageUp, + Hover, + Indent, + JoinLines, + LineDown, + LineUp, + MoveDown, + MoveLeft, + MoveLineDown, + MoveLineUp, + MoveRight, + MoveToBeginning, + MoveToBeginningOfLine, + MoveToEnclosingBracket, + MoveToEnd, + MoveToEndOfLine, + MoveToEndOfParagraph, + MoveToNextSubwordEnd, + MoveToNextWordEnd, + MoveToPreviousSubwordStart, + MoveToPreviousWordStart, + MoveToStartOfParagraph, + MoveUp, + Newline, + NewlineAbove, + NewlineBelow, + NextScreen, + OpenExcerpts, + Outdent, + PageDown, + PageUp, + Paste, + Redo, + RedoSelection, + Rename, + RestartLanguageServer, + RevealInFinder, + ReverseLines, + ScrollCursorBottom, + ScrollCursorCenter, + ScrollCursorTop, + SelectAll, + SelectDown, + SelectLargerSyntaxNode, + SelectLeft, + SelectLine, + SelectRight, + SelectSmallerSyntaxNode, + SelectToBeginning, + SelectToEnd, + SelectToEndOfParagraph, + SelectToNextSubwordEnd, + SelectToNextWordEnd, + SelectToPreviousSubwordStart, + SelectToPreviousWordStart, + SelectToStartOfParagraph, + SelectUp, + ShowCharacterPalette, + ShowCompletions, + ShuffleLines, + SortLinesCaseInsensitive, + SortLinesCaseSensitive, + SplitSelectionIntoLines, + Tab, + TabPrev, + ToggleInlayHints, + ToggleSoftWrap, + Transpose, + Undo, + UndoSelection, + UnfoldLines, + ] +); diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index 4f2d5179db..7ab5b0ff2a 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -30,7 +30,8 @@ pub use block_map::{ }; pub use self::fold_map::{Fold, FoldPoint}; -pub use self::inlay_map::{Inlay, InlayOffset, InlayPoint}; +pub use self::inlay_map::{InlayOffset, InlayPoint}; +pub(crate) use inlay_map::Inlay; #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum FoldStatus { @@ -220,7 +221,7 @@ impl DisplayMap { .insert(Some(type_id), Arc::new((style, ranges))); } - pub fn highlight_inlays( + pub(crate) fn highlight_inlays( &mut self, type_id: TypeId, highlights: Vec, @@ -258,11 +259,11 @@ impl DisplayMap { .update(cx, |map, cx| map.set_wrap_width(width, cx)) } - pub fn current_inlays(&self) -> impl Iterator { + pub(crate) fn current_inlays(&self) -> impl Iterator { self.inlay_map.current_inlays() } - pub fn splice_inlays( + pub(crate) fn splice_inlays( &mut self, to_remove: Vec, to_insert: Vec, @@ -306,7 +307,7 @@ impl DisplayMap { } #[derive(Debug, Default)] -pub struct Highlights<'a> { +pub(crate) struct Highlights<'a> { pub text_highlights: Option<&'a TextHighlights>, pub inlay_highlights: Option<&'a InlayHighlights>, pub inlay_highlight_style: Option, @@ -880,8 +881,9 @@ impl DisplaySnapshot { self.text_highlights.get(&Some(type_id)).cloned() } + #[allow(unused)] #[cfg(any(test, feature = "test-support"))] - pub fn inlay_highlights( + pub(crate) fn inlay_highlights( &self, ) -> Option<&HashMap> { let type_id = TypeId::of::(); diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index 6eb0d05bfe..dbbcbccb6e 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -582,7 +582,7 @@ impl BlockSnapshot { .collect() } - pub fn chunks<'a>( + pub(crate) fn chunks<'a>( &'a self, rows: Range, language_aware: bool, diff --git a/crates/editor/src/display_map/fold_map.rs b/crates/editor/src/display_map/fold_map.rs index 4dad2d52ae..7c6eeb444e 100644 --- a/crates/editor/src/display_map/fold_map.rs +++ b/crates/editor/src/display_map/fold_map.rs @@ -655,7 +655,7 @@ impl FoldSnapshot { } } - pub fn chunks<'a>( + pub(crate) fn chunks<'a>( &'a self, range: Range, language_aware: bool, diff --git a/crates/editor/src/display_map/inlay_map.rs b/crates/editor/src/display_map/inlay_map.rs index 84fad96a48..c0d5198ddd 100644 --- a/crates/editor/src/display_map/inlay_map.rs +++ b/crates/editor/src/display_map/inlay_map.rs @@ -35,8 +35,8 @@ enum Transform { } #[derive(Debug, Clone)] -pub struct Inlay { - pub id: InlayId, +pub(crate) struct Inlay { + pub(crate) id: InlayId, pub position: Anchor, pub text: text::Rope, } @@ -1016,7 +1016,7 @@ impl InlaySnapshot { (line_end - line_start) as u32 } - pub fn chunks<'a>( + pub(crate) fn chunks<'a>( &'a self, range: Range, language_aware: bool, diff --git a/crates/editor/src/display_map/wrap_map.rs b/crates/editor/src/display_map/wrap_map.rs index ce2e5ee3d9..39f9a2315b 100644 --- a/crates/editor/src/display_map/wrap_map.rs +++ b/crates/editor/src/display_map/wrap_map.rs @@ -568,7 +568,7 @@ impl WrapSnapshot { Patch::new(wrap_edits) } - pub fn chunks<'a>( + pub(crate) fn chunks<'a>( &'a self, rows: Range, language_aware: bool, diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 30b0a73d37..378607a4fb 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1,3 +1,18 @@ +#![allow(rustdoc::private_intra_doc_links)] +//! This is the place where everything editor-related is stored (data-wise) and displayed (ui-wise). +//! The main point of interest in this crate is [`Editor`] type, which is used in every other Zed part as a user input element. +//! It comes in different flavors: single line, multiline and a fixed height one. +//! +//! Editor contains of multiple large submodules: +//! * [`element`] — the place where all rendering happens +//! * [`display_map`] - chunks up text in the editor into the logical blocks, establishes coordinates and mapping between each of them. +//! Contains all metadata related to text transformations (folds, fake inlay text insertions, soft wraps, tab markup, etc.). +//! * [`inlay_hint_cache`] - is a storage of inlay hints out of LSP requests, responsible for querying LSP and updating `display_map`'s state accordingly. +//! +//! All other submodules and structs are mostly concerned with holding editor data about the way it displays current buffer region(s). +//! +//! If you're looking to improve Vim mode, you should check out Vim crate that wraps Editor and overrides it's behaviour. +pub mod actions; mod blink_manager; pub mod display_map; mod editor_settings; @@ -14,13 +29,14 @@ pub mod movement; mod persistence; mod rust_analyzer_ext; pub mod scroll; -pub mod selections_collection; +mod selections_collection; #[cfg(test)] mod editor_tests; #[cfg(any(test, feature = "test-support"))] pub mod test; use ::git::diff::DiffHunk; +pub(crate) use actions::*; use aho_corasick::AhoCorasick; use anyhow::{anyhow, Context as _, Result}; use blink_manager::BlinkManager; @@ -32,14 +48,13 @@ use copilot::Copilot; pub use display_map::DisplayPoint; use display_map::*; pub use editor_settings::EditorSettings; -pub use element::{ - Cursor, EditorElement, HighlightedRange, HighlightedRangeLine, LineWithInvisibles, -}; +use element::LineWithInvisibles; +pub use element::{Cursor, EditorElement, HighlightedRange, HighlightedRangeLine}; use futures::FutureExt; use fuzzy::{StringMatch, StringMatchCandidate}; use git::diff_hunk_to_display; use gpui::{ - actions, div, impl_actions, point, prelude::*, px, relative, rems, size, uniform_list, Action, + div, impl_actions, point, prelude::*, px, relative, rems, size, uniform_list, Action, AnyElement, AppContext, AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem, Context, DispatchPhase, ElementId, EventEmitter, FocusHandle, FocusableView, FontStyle, FontWeight, HighlightStyle, Hsla, InputHandler, InteractiveText, KeyContext, Model, MouseButton, @@ -51,7 +66,7 @@ use hover_popover::{hide_hover, HoverState}; use inlay_hint_cache::{InlayHintCache, InlaySplice, InvalidationStrategy}; pub use items::MAX_TAB_TITLE_LEN; use itertools::Itertools; -pub use language::{char_kind, CharKind}; +use language::{char_kind, CharKind}; use language::{ language_settings::{self, all_language_settings, InlayHintSettings}, markdown, point_from_lsp, AutoindentMode, BracketPair, Buffer, Capability, CodeAction, @@ -74,9 +89,7 @@ use parking_lot::RwLock; use project::{FormatTrigger, Location, Project, ProjectPath, ProjectTransaction}; use rand::prelude::*; use rpc::proto::{self, *}; -use scroll::{ - autoscroll::Autoscroll, OngoingScroll, ScrollAnchor, ScrollManager, ScrollbarAutoHide, -}; +use scroll::{Autoscroll, OngoingScroll, ScrollAnchor, ScrollManager, ScrollbarAutoHide}; use selections_collection::{resolve_multiple, MutableSelectionsCollection, SelectionsCollection}; use serde::{Deserialize, Serialize}; use settings::{Settings, SettingsStore}; @@ -113,10 +126,12 @@ const MAX_LINE_LEN: usize = 1024; const MIN_NAVIGATION_HISTORY_ROW_DELTA: i64 = 10; const MAX_SELECTION_HISTORY_LEN: usize = 1024; const COPILOT_DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(75); +#[doc(hidden)] pub const CODE_ACTIONS_DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(250); +#[doc(hidden)] pub const DOCUMENT_HIGHLIGHTS_DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(75); -pub const FORMAT_TIMEOUT: Duration = Duration::from_secs(2); +pub(crate) const FORMAT_TIMEOUT: Duration = Duration::from_secs(2); pub fn render_parsed_markdown( element_id: impl Into, @@ -181,103 +196,8 @@ pub fn render_parsed_markdown( }) } -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct SelectNext { - #[serde(default)] - pub replace_newest: bool, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct SelectPrevious { - #[serde(default)] - pub replace_newest: bool, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct SelectAllMatches { - #[serde(default)] - pub replace_newest: bool, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct SelectToBeginningOfLine { - #[serde(default)] - stop_at_soft_wraps: bool, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct MovePageUp { - #[serde(default)] - center_cursor: bool, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct MovePageDown { - #[serde(default)] - center_cursor: bool, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct SelectToEndOfLine { - #[serde(default)] - stop_at_soft_wraps: bool, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct ToggleCodeActions { - #[serde(default)] - pub deployed_from_indicator: bool, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct ConfirmCompletion { - #[serde(default)] - pub item_ix: Option, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct ConfirmCodeAction { - #[serde(default)] - pub item_ix: Option, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct ToggleComments { - #[serde(default)] - pub advance_downwards: bool, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct FoldAt { - pub buffer_row: u32, -} - -#[derive(PartialEq, Clone, Deserialize, Default)] -pub struct UnfoldAt { - pub buffer_row: u32, -} - -impl_actions!( - editor, - [ - SelectNext, - SelectPrevious, - SelectAllMatches, - SelectToBeginningOfLine, - MovePageUp, - MovePageDown, - SelectToEndOfLine, - ToggleCodeActions, - ConfirmCompletion, - ConfirmCodeAction, - ToggleComments, - FoldAt, - UnfoldAt - ] -); - #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum InlayId { +pub(crate) enum InlayId { Suggestion(usize), Hint(usize), } @@ -291,128 +211,6 @@ impl InlayId { } } -actions!( - editor, - [ - AddSelectionAbove, - AddSelectionBelow, - Backspace, - Cancel, - ConfirmRename, - ContextMenuFirst, - ContextMenuLast, - ContextMenuNext, - ContextMenuPrev, - ConvertToKebabCase, - ConvertToLowerCamelCase, - ConvertToLowerCase, - ConvertToSnakeCase, - ConvertToTitleCase, - ConvertToUpperCamelCase, - ConvertToUpperCase, - Copy, - CopyHighlightJson, - CopyPath, - CopyRelativePath, - Cut, - CutToEndOfLine, - Delete, - DeleteLine, - DeleteToBeginningOfLine, - DeleteToEndOfLine, - DeleteToNextSubwordEnd, - DeleteToNextWordEnd, - DeleteToPreviousSubwordStart, - DeleteToPreviousWordStart, - DuplicateLine, - ExpandMacroRecursively, - FindAllReferences, - Fold, - FoldSelectedRanges, - Format, - GoToDefinition, - GoToDefinitionSplit, - GoToDiagnostic, - GoToHunk, - GoToPrevDiagnostic, - GoToPrevHunk, - GoToTypeDefinition, - GoToTypeDefinitionSplit, - HalfPageDown, - HalfPageUp, - Hover, - Indent, - JoinLines, - LineDown, - LineUp, - MoveDown, - MoveLeft, - MoveLineDown, - MoveLineUp, - MoveRight, - MoveToBeginning, - MoveToBeginningOfLine, - MoveToEnclosingBracket, - MoveToEnd, - MoveToEndOfLine, - MoveToEndOfParagraph, - MoveToNextSubwordEnd, - MoveToNextWordEnd, - MoveToPreviousSubwordStart, - MoveToPreviousWordStart, - MoveToStartOfParagraph, - MoveUp, - Newline, - NewlineAbove, - NewlineBelow, - NextScreen, - OpenExcerpts, - Outdent, - PageDown, - PageUp, - Paste, - Redo, - RedoSelection, - Rename, - RestartLanguageServer, - RevealInFinder, - ReverseLines, - ScrollCursorBottom, - ScrollCursorCenter, - ScrollCursorTop, - SelectAll, - SelectDown, - SelectLargerSyntaxNode, - SelectLeft, - SelectLine, - SelectRight, - SelectSmallerSyntaxNode, - SelectToBeginning, - SelectToEnd, - SelectToEndOfParagraph, - SelectToNextSubwordEnd, - SelectToNextWordEnd, - SelectToPreviousSubwordStart, - SelectToPreviousWordStart, - SelectToStartOfParagraph, - SelectUp, - ShowCharacterPalette, - ShowCompletions, - ShuffleLines, - SortLinesCaseInsensitive, - SortLinesCaseSensitive, - SplitSelectionIntoLines, - Tab, - TabPrev, - ToggleInlayHints, - ToggleSoftWrap, - Transpose, - Undo, - UndoSelection, - UnfoldLines, - ] -); - enum DocumentHighlightRead {} enum DocumentHighlightWrite {} enum InputComposition {} @@ -489,7 +287,7 @@ pub enum SelectPhase { } #[derive(Clone, Debug)] -pub enum SelectMode { +pub(crate) enum SelectMode { Character, Word(Range), Line(Range), @@ -760,6 +558,7 @@ struct SnippetState { active_index: usize, } +#[doc(hidden)] pub struct RenameState { pub range: Range, pub old_name: Arc, @@ -1499,7 +1298,7 @@ impl CodeActionsMenu { } } -pub struct CopilotState { +pub(crate) struct CopilotState { excerpt_id: Option, pending_refresh: Task>, pending_cycling_refresh: Task>, @@ -1619,15 +1418,13 @@ pub struct ClipboardSelection { } #[derive(Debug)] -pub struct NavigationData { +pub(crate) struct NavigationData { cursor_anchor: Anchor, cursor_position: Point, scroll_anchor: ScrollAnchor, scroll_top_row: u32, } -pub struct EditorCreated(pub View); - enum GotoDefinitionKind { Symbol, Type, @@ -8125,7 +7922,7 @@ impl Editor { } } - pub fn fold(&mut self, _: &Fold, cx: &mut ViewContext) { + pub fn fold(&mut self, _: &actions::Fold, cx: &mut ViewContext) { let mut fold_ranges = Vec::new(); let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx)); @@ -8484,7 +8281,7 @@ impl Editor { cx.notify(); } - pub fn highlight_inlay_background( + pub(crate) fn highlight_inlay_background( &mut self, ranges: Vec, color_fetcher: fn(&ThemeColors) -> Hsla, @@ -8691,7 +8488,7 @@ impl Editor { cx.notify(); } - pub fn highlight_inlays( + pub(crate) fn highlight_inlays( &mut self, highlights: Vec, style: HighlightStyle, @@ -9899,7 +9696,7 @@ pub fn highlight_diagnostic_message(diagnostic: &Diagnostic) -> (SharedString, V (text_without_backticks.into(), code_ranges) } -pub fn diagnostic_style(severity: DiagnosticSeverity, valid: bool, colors: &StatusColors) -> Hsla { +fn diagnostic_style(severity: DiagnosticSeverity, valid: bool, colors: &StatusColors) -> Hsla { match (severity, valid) { (DiagnosticSeverity::ERROR, true) => colors.error, (DiagnosticSeverity::ERROR, false) => colors.error, @@ -9958,7 +9755,7 @@ pub fn styled_runs_for_code_label<'a>( }) } -pub fn split_words<'a>(text: &'a str) -> impl std::iter::Iterator + 'a { +pub(crate) fn split_words<'a>(text: &'a str) -> impl std::iter::Iterator + 'a { let mut index = 0; let mut codepoints = text.char_indices().peekable(); diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index b82bd55bcf..64c0fdeb64 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2599,7 +2599,7 @@ impl EditorElement { } #[derive(Debug)] -pub struct LineWithInvisibles { +pub(crate) struct LineWithInvisibles { pub line: ShapedLine, invisibles: Vec, } diff --git a/crates/editor/src/inlay_hint_cache.rs b/crates/editor/src/inlay_hint_cache.rs index 59c6b8605c..73c9b5dcd7 100644 --- a/crates/editor/src/inlay_hint_cache.rs +++ b/crates/editor/src/inlay_hint_cache.rs @@ -1,3 +1,11 @@ +/// Stores and updates all data received from LSP textDocument/inlayHint requests. +/// Has nothing to do with other inlays, e.g. copilot suggestions — those are stored elsewhere. +/// On every update, cache may query for more inlay hints and update inlays on the screen. +/// +/// Inlays stored on screen are in [`crate::display_map::inlay_map`] and this cache is the only way to update any inlay hint data in the visible hints in the inlay map. +/// For determining the update to the `inlay_map`, the cache requires a list of visible inlay hints — all other hints are not relevant and their separate updates are not influencing the cache work. +/// +/// Due to the way the data is stored for both visible inlays and the cache, every inlay (and inlay hint) collection is editor-specific, so a single buffer may have multiple sets of inlays of open on different panes. use std::{ cmp, ops::{ControlFlow, Range}, @@ -39,7 +47,7 @@ struct TasksForRanges { } #[derive(Debug)] -pub struct CachedExcerptHints { +struct CachedExcerptHints { version: usize, buffer_version: Global, buffer_id: u64, @@ -47,15 +55,30 @@ pub struct CachedExcerptHints { hints_by_id: HashMap, } +/// A logic to apply when querying for new inlay hints and deciding what to do with the old entries in the cache in case of conflicts. #[derive(Debug, Clone, Copy)] -pub enum InvalidationStrategy { +pub(super) enum InvalidationStrategy { + /// Hints reset is requested by the LSP server. + /// Demands to re-query all inlay hints needed and invalidate all cached entries, but does not require instant update with invalidation. + /// + /// Despite nothing forbids language server from sending this request on every edit, it is expected to be sent only when certain internal server state update, invisible for the editor otherwise. RefreshRequested, + /// Multibuffer excerpt(s) and/or singleton buffer(s) were edited at least on one place. + /// Neither editor nor LSP is able to tell which open file hints' are not affected, so all of them have to be invalidated, re-queried and do that fast enough to avoid being slow, but also debounce to avoid loading hints on every fast keystroke sequence. BufferEdited, + /// A new file got opened/new excerpt was added to a multibuffer/a [multi]buffer was scrolled to a new position. + /// No invalidation should be done at all, all new hints are added to the cache. + /// + /// A special case is the settings change: in addition to LSP capabilities, Zed allows omitting certain hint kinds (defined by the corresponding LSP part: type/parameter/other). + /// This does not lead to cache invalidation, but would require cache usage for determining which hints are not displayed and issuing an update to inlays on the screen. None, } -#[derive(Debug, Default)] -pub struct InlaySplice { +/// A splice to send into the `inlay_map` for updating the visible inlays on the screen. +/// "Visible" inlays may not be displayed in the buffer right away, but those are ready to be displayed on further buffer scroll, pane item activations, etc. right away without additional LSP queries or settings changes. +/// The data in the cache is never used directly for displaying inlays on the screen, to avoid races with updates from LSP queries and sync overhead. +/// Splice is picked to help avoid extra hint flickering and "jumps" on the screen. +pub(super) struct InlaySplice { pub to_remove: Vec, pub to_insert: Vec, } @@ -237,7 +260,7 @@ impl TasksForRanges { } impl InlayHintCache { - pub fn new(inlay_hint_settings: InlayHintSettings) -> Self { + pub(super) fn new(inlay_hint_settings: InlayHintSettings) -> Self { Self { allowed_hint_kinds: inlay_hint_settings.enabled_inlay_hint_kinds(), enabled: inlay_hint_settings.enabled, @@ -248,7 +271,10 @@ impl InlayHintCache { } } - pub fn update_settings( + /// Checks inlay hint settings for enabled hint kinds and general enabled state. + /// Generates corresponding inlay_map splice updates on settings changes. + /// Does not update inlay hint cache state on disabling or inlay hint kinds change: only reenabling forces new LSP queries. + pub(super) fn update_settings( &mut self, multi_buffer: &Model, new_hint_settings: InlayHintSettings, @@ -299,7 +325,11 @@ impl InlayHintCache { } } - pub fn spawn_hint_refresh( + /// If needed, queries LSP for new inlay hints, using the invalidation strategy given. + /// To reduce inlay hint jumping, attempts to query a visible range of the editor(s) first, + /// followed by the delayed queries of the same range above and below the visible one. + /// This way, concequent refresh invocations are less likely to trigger LSP queries for the invisible ranges. + pub(super) fn spawn_hint_refresh( &mut self, reason: &'static str, excerpts_to_query: HashMap, Global, Range)>, @@ -460,7 +490,11 @@ impl InlayHintCache { } } - pub fn remove_excerpts(&mut self, excerpts_removed: Vec) -> Option { + /// Completely forget of certain excerpts that were removed from the multibuffer. + pub(super) fn remove_excerpts( + &mut self, + excerpts_removed: Vec, + ) -> Option { let mut to_remove = Vec::new(); for excerpt_to_remove in excerpts_removed { self.update_tasks.remove(&excerpt_to_remove); @@ -480,7 +514,7 @@ impl InlayHintCache { } } - pub fn clear(&mut self) { + pub(super) fn clear(&mut self) { if !self.update_tasks.is_empty() || !self.hints.is_empty() { self.version += 1; } @@ -488,7 +522,7 @@ impl InlayHintCache { self.hints.clear(); } - pub fn hint_by_id(&self, excerpt_id: ExcerptId, hint_id: InlayId) -> Option { + pub(super) fn hint_by_id(&self, excerpt_id: ExcerptId, hint_id: InlayId) -> Option { self.hints .get(&excerpt_id)? .read() @@ -516,7 +550,8 @@ impl InlayHintCache { self.version } - pub fn spawn_hint_resolve( + /// Queries a certain hint from the cache for extra data via the LSP resolve request. + pub(super) fn spawn_hint_resolve( &self, buffer_id: u64, excerpt_id: ExcerptId, @@ -1199,7 +1234,7 @@ pub mod tests { use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}; use crate::{ - scroll::{autoscroll::Autoscroll, scroll_amount::ScrollAmount}, + scroll::{scroll_amount::ScrollAmount, Autoscroll}, ExcerptRange, }; use futures::StreamExt; diff --git a/crates/editor/src/link_go_to_definition.rs b/crates/editor/src/link_go_to_definition.rs index 04dcf93015..c4da7fcd38 100644 --- a/crates/editor/src/link_go_to_definition.rs +++ b/crates/editor/src/link_go_to_definition.rs @@ -69,7 +69,7 @@ pub enum GoToDefinitionLink { } #[derive(Debug, Clone, PartialEq, Eq)] -pub struct InlayHighlight { +pub(crate) struct InlayHighlight { pub inlay: InlayId, pub inlay_position: Anchor, pub range: Range, diff --git a/crates/editor/src/movement.rs b/crates/editor/src/movement.rs index 72441974c3..0cf8ac7440 100644 --- a/crates/editor/src/movement.rs +++ b/crates/editor/src/movement.rs @@ -1,3 +1,6 @@ +//! Movement module contains helper functions for calculating intended position +//! in editor given a given motion (e.g. it handles converting a "move left" command into coordinates in editor). It is exposed mostly for use by vim crate. + use super::{Bias, DisplayPoint, DisplaySnapshot, SelectionGoal, ToDisplayPoint}; use crate::{char_kind, CharKind, EditorStyle, ToOffset, ToPoint}; use gpui::{px, Pixels, TextSystem}; @@ -5,6 +8,9 @@ use language::Point; use std::{ops::Range, sync::Arc}; +/// Defines search strategy for items in `movement` module. +/// `FindRange::SingeLine` only looks for a match on a single line at a time, whereas +/// `FindRange::MultiLine` keeps going until the end of a string. #[derive(Debug, PartialEq)] pub enum FindRange { SingleLine, @@ -14,11 +20,13 @@ pub enum FindRange { /// TextLayoutDetails encompasses everything we need to move vertically /// taking into account variable width characters. pub struct TextLayoutDetails { - pub text_system: Arc, - pub editor_style: EditorStyle, - pub rem_size: Pixels, + pub(crate) text_system: Arc, + pub(crate) editor_style: EditorStyle, + pub(crate) rem_size: Pixels, } +/// Returns a column to the left of the current point, wrapping +/// to the previous line if that point is at the start of line. pub fn left(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint { if point.column() > 0 { *point.column_mut() -= 1; @@ -29,6 +37,8 @@ pub fn left(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint { map.clip_point(point, Bias::Left) } +/// Returns a column to the left of the current point, doing nothing if +/// that point is already at the start of line. pub fn saturating_left(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint { if point.column() > 0 { *point.column_mut() -= 1; @@ -36,6 +46,8 @@ pub fn saturating_left(map: &DisplaySnapshot, mut point: DisplayPoint) -> Displa map.clip_point(point, Bias::Left) } +/// Returns a column to the right of the current point, wrapping +/// to the next line if that point is at the end of line. pub fn right(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint { let max_column = map.line_len(point.row()); if point.column() < max_column { @@ -47,11 +59,14 @@ pub fn right(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint { map.clip_point(point, Bias::Right) } +/// Returns a column to the right of the current point, not performing any wrapping +/// if that point is already at the end of line. pub fn saturating_right(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint { *point.column_mut() += 1; map.clip_point(point, Bias::Right) } +/// Returns a display point for the preceding displayed line (which might be a soft-wrapped line). pub fn up( map: &DisplaySnapshot, start: DisplayPoint, @@ -69,6 +84,7 @@ pub fn up( ) } +/// Returns a display point for the next displayed line (which might be a soft-wrapped line). pub fn down( map: &DisplaySnapshot, start: DisplayPoint, @@ -86,7 +102,7 @@ pub fn down( ) } -pub fn up_by_rows( +pub(crate) fn up_by_rows( map: &DisplaySnapshot, start: DisplayPoint, row_count: u32, @@ -125,7 +141,7 @@ pub fn up_by_rows( ) } -pub fn down_by_rows( +pub(crate) fn down_by_rows( map: &DisplaySnapshot, start: DisplayPoint, row_count: u32, @@ -161,6 +177,10 @@ pub fn down_by_rows( ) } +/// Returns a position of the start of line. +/// If `stop_at_soft_boundaries` is true, the returned position is that of the +/// displayed line (e.g. it could actually be in the middle of a text line if that line is soft-wrapped). +/// Otherwise it's always going to be the start of a logical line. pub fn line_beginning( map: &DisplaySnapshot, display_point: DisplayPoint, @@ -177,6 +197,10 @@ pub fn line_beginning( } } +/// Returns the last indented position on a given line. +/// If `stop_at_soft_boundaries` is true, the returned [`DisplayPoint`] is that of a +/// displayed line (e.g. if there's soft wrap it's gonna be returned), +/// otherwise it's always going to be a start of a logical line. pub fn indented_line_beginning( map: &DisplaySnapshot, display_point: DisplayPoint, @@ -201,6 +225,11 @@ pub fn indented_line_beginning( } } +/// Returns a position of the end of line. + +/// If `stop_at_soft_boundaries` is true, the returned position is that of the +/// displayed line (e.g. it could actually be in the middle of a text line if that line is soft-wrapped). +/// Otherwise it's always going to be the end of a logical line. pub fn line_end( map: &DisplaySnapshot, display_point: DisplayPoint, @@ -217,6 +246,8 @@ pub fn line_end( } } +/// Returns a position of the previous word boundary, where a word character is defined as either +/// uppercase letter, lowercase letter, '_' character or language-specific word character (like '-' in CSS). pub fn previous_word_start(map: &DisplaySnapshot, point: DisplayPoint) -> DisplayPoint { let raw_point = point.to_point(map); let scope = map.buffer_snapshot.language_scope_at(raw_point); @@ -227,6 +258,9 @@ pub fn previous_word_start(map: &DisplaySnapshot, point: DisplayPoint) -> Displa }) } +/// Returns a position of the previous subword boundary, where a subword is defined as a run of +/// word characters of the same "subkind" - where subcharacter kinds are '_' character, +/// lowerspace characters and uppercase characters. pub fn previous_subword_start(map: &DisplaySnapshot, point: DisplayPoint) -> DisplayPoint { let raw_point = point.to_point(map); let scope = map.buffer_snapshot.language_scope_at(raw_point); @@ -240,6 +274,8 @@ pub fn previous_subword_start(map: &DisplaySnapshot, point: DisplayPoint) -> Dis }) } +/// Returns a position of the next word boundary, where a word character is defined as either +/// uppercase letter, lowercase letter, '_' character or language-specific word character (like '-' in CSS). pub fn next_word_end(map: &DisplaySnapshot, point: DisplayPoint) -> DisplayPoint { let raw_point = point.to_point(map); let scope = map.buffer_snapshot.language_scope_at(raw_point); @@ -250,6 +286,9 @@ pub fn next_word_end(map: &DisplaySnapshot, point: DisplayPoint) -> DisplayPoint }) } +/// Returns a position of the next subword boundary, where a subword is defined as a run of +/// word characters of the same "subkind" - where subcharacter kinds are '_' character, +/// lowerspace characters and uppercase characters. pub fn next_subword_end(map: &DisplaySnapshot, point: DisplayPoint) -> DisplayPoint { let raw_point = point.to_point(map); let scope = map.buffer_snapshot.language_scope_at(raw_point); @@ -263,6 +302,8 @@ pub fn next_subword_end(map: &DisplaySnapshot, point: DisplayPoint) -> DisplayPo }) } +/// Returns a position of the start of the current paragraph, where a paragraph +/// is defined as a run of non-blank lines. pub fn start_of_paragraph( map: &DisplaySnapshot, display_point: DisplayPoint, @@ -290,6 +331,8 @@ pub fn start_of_paragraph( DisplayPoint::zero() } +/// Returns a position of the end of the current paragraph, where a paragraph +/// is defined as a run of non-blank lines. pub fn end_of_paragraph( map: &DisplaySnapshot, display_point: DisplayPoint, @@ -376,6 +419,9 @@ pub fn find_boundary( map.clip_point(offset.to_display_point(map), Bias::Right) } +/// Returns an iterator over the characters following a given offset in the [`DisplaySnapshot`]. +/// The returned value also contains a range of the start/end of a returned character in +/// the [`DisplaySnapshot`]. The offsets are relative to the start of a buffer. pub fn chars_after( map: &DisplaySnapshot, mut offset: usize, @@ -387,6 +433,9 @@ pub fn chars_after( }) } +/// Returns a reverse iterator over the characters following a given offset in the [`DisplaySnapshot`]. +/// The returned value also contains a range of the start/end of a returned character in +/// the [`DisplaySnapshot`]. The offsets are relative to the start of a buffer. pub fn chars_before( map: &DisplaySnapshot, mut offset: usize, @@ -400,7 +449,7 @@ pub fn chars_before( }) } -pub fn is_inside_word(map: &DisplaySnapshot, point: DisplayPoint) -> bool { +pub(crate) fn is_inside_word(map: &DisplaySnapshot, point: DisplayPoint) -> bool { let raw_point = point.to_point(map); let scope = map.buffer_snapshot.language_scope_at(raw_point); let ix = map.clip_point(point, Bias::Left).to_offset(map, Bias::Left); @@ -413,7 +462,10 @@ pub fn is_inside_word(map: &DisplaySnapshot, point: DisplayPoint) -> bool { prev_char_kind.zip(next_char_kind) == Some((CharKind::Word, CharKind::Word)) } -pub fn surrounding_word(map: &DisplaySnapshot, position: DisplayPoint) -> Range { +pub(crate) fn surrounding_word( + map: &DisplaySnapshot, + position: DisplayPoint, +) -> Range { let position = map .clip_point(position, Bias::Left) .to_offset(map, Bias::Left); @@ -429,6 +481,12 @@ pub fn surrounding_word(map: &DisplaySnapshot, position: DisplayPoint) -> Range< start..end } +/// Returns a list of lines (represented as a [`DisplayPoint`] range) contained +/// within a passed range. +/// +/// The line ranges are **always* going to be in bounds of a requested range, which means that +/// the first and the last lines might not necessarily represent the +/// full range of a logical line (as their `.start`/`.end` values are clipped to those of a passed in range). pub fn split_display_range_by_lines( map: &DisplaySnapshot, range: Range, diff --git a/crates/editor/src/scroll.rs b/crates/editor/src/scroll.rs index bc5fe4bddd..f68004109e 100644 --- a/crates/editor/src/scroll.rs +++ b/crates/editor/src/scroll.rs @@ -1,6 +1,6 @@ -pub mod actions; -pub mod autoscroll; -pub mod scroll_amount; +mod actions; +pub(crate) mod autoscroll; +pub(crate) mod scroll_amount; use crate::{ display_map::{DisplaySnapshot, ToDisplayPoint}, @@ -9,8 +9,10 @@ use crate::{ Anchor, DisplayPoint, Editor, EditorEvent, EditorMode, InlayHintRefreshReason, MultiBufferSnapshot, ToPoint, }; +pub use autoscroll::{Autoscroll, AutoscrollStrategy}; use gpui::{point, px, AppContext, Entity, Pixels, Task, ViewContext}; use language::{Bias, Point}; +pub use scroll_amount::ScrollAmount; use std::{ cmp::Ordering, time::{Duration, Instant}, @@ -18,11 +20,6 @@ use std::{ use util::ResultExt; use workspace::{ItemId, WorkspaceId}; -use self::{ - autoscroll::{Autoscroll, AutoscrollStrategy}, - scroll_amount::ScrollAmount, -}; - pub const SCROLL_EVENT_SEPARATION: Duration = Duration::from_millis(28); pub const VERTICAL_SCROLL_MARGIN: f32 = 3.; const SCROLLBAR_SHOW_INTERVAL: Duration = Duration::from_secs(1); diff --git a/crates/editor/src/scroll/autoscroll.rs b/crates/editor/src/scroll/autoscroll.rs index 2a5ac568b7..955b970540 100644 --- a/crates/editor/src/scroll/autoscroll.rs +++ b/crates/editor/src/scroll/autoscroll.rs @@ -175,7 +175,7 @@ impl Editor { true } - pub fn autoscroll_horizontally( + pub(crate) fn autoscroll_horizontally( &mut self, start_row: u32, viewport_width: Pixels, diff --git a/crates/editor/src/selections_collection.rs b/crates/editor/src/selections_collection.rs index 8d71916210..96f9507dd2 100644 --- a/crates/editor/src/selections_collection.rs +++ b/crates/editor/src/selections_collection.rs @@ -99,7 +99,7 @@ impl SelectionsCollection { .map(|pending| pending.map(|p| p.summary::(&self.buffer(cx)))) } - pub fn pending_mode(&self) -> Option { + pub(crate) fn pending_mode(&self) -> Option { self.pending.as_ref().map(|pending| pending.mode.clone()) } @@ -398,7 +398,7 @@ impl<'a> MutableSelectionsCollection<'a> { } } - pub fn set_pending_anchor_range(&mut self, range: Range, mode: SelectMode) { + pub(crate) fn set_pending_anchor_range(&mut self, range: Range, mode: SelectMode) { self.collection.pending = Some(PendingSelection { selection: Selection { id: post_inc(&mut self.collection.next_selection_id), @@ -412,7 +412,11 @@ impl<'a> MutableSelectionsCollection<'a> { self.selections_changed = true; } - pub fn set_pending_display_range(&mut self, range: Range, mode: SelectMode) { + pub(crate) fn set_pending_display_range( + &mut self, + range: Range, + mode: SelectMode, + ) { let (start, end, reversed) = { let display_map = self.display_map(); let buffer = self.buffer(); @@ -448,7 +452,7 @@ impl<'a> MutableSelectionsCollection<'a> { self.selections_changed = true; } - pub fn set_pending(&mut self, selection: Selection, mode: SelectMode) { + pub(crate) fn set_pending(&mut self, selection: Selection, mode: SelectMode) { self.collection.pending = Some(PendingSelection { selection, mode }); self.selections_changed = true; } @@ -855,7 +859,7 @@ impl<'a> DerefMut for MutableSelectionsCollection<'a> { } // Panics if passed selections are not in order -pub fn resolve_multiple<'a, D, I>( +pub(crate) fn resolve_multiple<'a, D, I>( selections: I, snapshot: &MultiBufferSnapshot, ) -> impl 'a + Iterator> diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index 022860ea47..8484843c87 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -1,5 +1,5 @@ use collections::HashMap; -use editor::{scroll::autoscroll::Autoscroll, Bias, Editor}; +use editor::{scroll::Autoscroll, Bias, Editor}; use fuzzy::{CharBag, PathMatch, PathMatchCandidate}; use gpui::{ actions, rems, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, Model, diff --git a/crates/go_to_line/src/go_to_line.rs b/crates/go_to_line/src/go_to_line.rs index b7e3f27fac..0a74f1ac03 100644 --- a/crates/go_to_line/src/go_to_line.rs +++ b/crates/go_to_line/src/go_to_line.rs @@ -1,4 +1,4 @@ -use editor::{display_map::ToDisplayPoint, scroll::autoscroll::Autoscroll, Editor}; +use editor::{display_map::ToDisplayPoint, scroll::Autoscroll, Editor}; use gpui::{ actions, div, prelude::*, AnyWindowHandle, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, Render, SharedString, Styled, Subscription, View, ViewContext, VisualContext, diff --git a/crates/journal/src/journal.rs b/crates/journal/src/journal.rs index 1ffab2f3d3..b15da05e17 100644 --- a/crates/journal/src/journal.rs +++ b/crates/journal/src/journal.rs @@ -1,6 +1,6 @@ use anyhow::Result; use chrono::{Datelike, Local, NaiveTime, Timelike}; -use editor::scroll::autoscroll::Autoscroll; +use editor::scroll::Autoscroll; use editor::Editor; use gpui::{actions, AppContext, ViewContext, WindowContext}; use schemars::JsonSchema; diff --git a/crates/language_tools/src/lsp_log.rs b/crates/language_tools/src/lsp_log.rs index 75b4305b58..b4e2b37e83 100644 --- a/crates/language_tools/src/lsp_log.rs +++ b/crates/language_tools/src/lsp_log.rs @@ -1,5 +1,5 @@ use collections::{HashMap, VecDeque}; -use editor::{Editor, EditorEvent, MoveToEnd}; +use editor::{actions::MoveToEnd, Editor, EditorEvent}; use futures::{channel::mpsc, StreamExt}; use gpui::{ actions, div, AnchorCorner, AnyElement, AppContext, Context, EventEmitter, FocusHandle, diff --git a/crates/language_tools/src/syntax_tree_view.rs b/crates/language_tools/src/syntax_tree_view.rs index 5acc6bff7f..be677b215b 100644 --- a/crates/language_tools/src/syntax_tree_view.rs +++ b/crates/language_tools/src/syntax_tree_view.rs @@ -1,4 +1,4 @@ -use editor::{scroll::autoscroll::Autoscroll, Anchor, Editor, ExcerptId}; +use editor::{scroll::Autoscroll, Anchor, Editor, ExcerptId}; use gpui::{ actions, canvas, div, rems, uniform_list, AnyElement, AppContext, AvailableSpace, Div, EventEmitter, FocusHandle, FocusableView, Hsla, InteractiveElement, IntoElement, Model, diff --git a/crates/outline/src/outline.rs b/crates/outline/src/outline.rs index 1f21120039..53f78b8fbd 100644 --- a/crates/outline/src/outline.rs +++ b/crates/outline/src/outline.rs @@ -1,6 +1,6 @@ use editor::{ - display_map::ToDisplayPoint, scroll::autoscroll::Autoscroll, Anchor, AnchorRangeExt, - DisplayPoint, Editor, EditorMode, ToPoint, + display_map::ToDisplayPoint, scroll::Autoscroll, Anchor, AnchorRangeExt, DisplayPoint, Editor, + EditorMode, ToPoint, }; use fuzzy::StringMatch; use gpui::{ diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 4301b6e392..79c158048e 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -3,7 +3,7 @@ mod project_panel_settings; use settings::Settings; use db::kvp::KEY_VALUE_STORE; -use editor::{scroll::autoscroll::Autoscroll, Cancel, Editor}; +use editor::{actions::Cancel, scroll::Autoscroll, Editor}; use file_associations::FileAssociations; use anyhow::{anyhow, Result}; diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs index 68a0721b4c..3d3e232895 100644 --- a/crates/project_symbols/src/project_symbols.rs +++ b/crates/project_symbols/src/project_symbols.rs @@ -1,4 +1,4 @@ -use editor::{scroll::autoscroll::Autoscroll, styled_runs_for_code_label, Bias, Editor}; +use editor::{scroll::Autoscroll, styled_runs_for_code_label, Bias, Editor}; use fuzzy::{StringMatch, StringMatchCandidate}; use gpui::{ actions, rems, AppContext, DismissEvent, FontWeight, Model, ParentElement, StyledText, Task, diff --git a/crates/quick_action_bar/src/quick_action_bar.rs b/crates/quick_action_bar/src/quick_action_bar.rs index 865632142a..3e49328c13 100644 --- a/crates/quick_action_bar/src/quick_action_bar.rs +++ b/crates/quick_action_bar/src/quick_action_bar.rs @@ -45,13 +45,13 @@ impl Render for QuickActionBar { "toggle inlay hints", IconName::InlayHint, editor.read(cx).inlay_hints_enabled(), - Box::new(editor::ToggleInlayHints), + Box::new(editor::actions::ToggleInlayHints), "Toggle Inlay Hints", { let editor = editor.clone(); move |_, cx| { editor.update(cx, |editor, cx| { - editor.toggle_inlay_hints(&editor::ToggleInlayHints, cx); + editor.toggle_inlay_hints(&editor::actions::ToggleInlayHints, cx); }); } }, diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index c4e3ea5b5c..a1f0d9773b 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -7,7 +7,7 @@ use crate::{ ToggleCaseSensitive, ToggleReplace, ToggleWholeWord, }; use collections::HashMap; -use editor::{Editor, EditorElement, EditorStyle, Tab}; +use editor::{actions::Tab, Editor, EditorElement, EditorStyle}; use futures::channel::oneshot; use gpui::{ actions, div, impl_actions, Action, AppContext, ClickEvent, EventEmitter, FocusableView, @@ -635,7 +635,7 @@ impl BufferSearchBar { registrar.register_handler(|this, action: &SelectAllMatches, cx| { this.select_all_matches(action, cx); }); - registrar.register_handler(|this, _: &editor::Cancel, cx| { + registrar.register_handler(|this, _: &editor::actions::Cancel, cx| { this.dismiss(&Dismiss, cx); }); registrar.register_handler_for_dismissed_search(|this, deploy, cx| { diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 098fa184e3..919129ef76 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -7,8 +7,8 @@ use crate::{ use anyhow::{Context as _, Result}; use collections::HashMap; use editor::{ - items::active_match_index, scroll::autoscroll::Autoscroll, Anchor, Editor, EditorEvent, - MultiBuffer, SelectAll, MAX_TAB_TITLE_LEN, + actions::SelectAll, items::active_match_index, scroll::Autoscroll, Anchor, Editor, EditorEvent, + MultiBuffer, MAX_TAB_TITLE_LEN, }; use editor::{EditorElement, EditorStyle}; use gpui::{ @@ -1383,11 +1383,11 @@ impl ProjectSearchBar { } } - fn tab(&mut self, _: &editor::Tab, cx: &mut ViewContext) { + fn tab(&mut self, _: &editor::actions::Tab, cx: &mut ViewContext) { self.cycle_field(Direction::Next, cx); } - fn tab_previous(&mut self, _: &editor::TabPrev, cx: &mut ViewContext) { + fn tab_previous(&mut self, _: &editor::actions::TabPrev, cx: &mut ViewContext) { self.cycle_field(Direction::Prev, cx); } diff --git a/crates/storybook/src/stories/auto_height_editor.rs b/crates/storybook/src/stories/auto_height_editor.rs index 6d83515562..7b3cee92c8 100644 --- a/crates/storybook/src/stories/auto_height_editor.rs +++ b/crates/storybook/src/stories/auto_height_editor.rs @@ -10,7 +10,11 @@ pub struct AutoHeightEditorStory { impl AutoHeightEditorStory { pub fn new(cx: &mut WindowContext) -> View { - cx.bind_keys([KeyBinding::new("enter", editor::Newline, Some("Editor"))]); + cx.bind_keys([KeyBinding::new( + "enter", + editor::actions::Newline, + Some("Editor"), + )]); cx.new_view(|cx| Self { editor: cx.new_view(|cx| { let mut editor = Editor::auto_height(3, cx); diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index db4b21627f..16e1ca4a73 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -2,7 +2,7 @@ mod persistence; pub mod terminal_element; pub mod terminal_panel; -use editor::{scroll::autoscroll::Autoscroll, Editor}; +use editor::{scroll::Autoscroll, Editor}; use gpui::{ div, impl_actions, overlay, AnyElement, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, KeyContext, KeyDownEvent, Keystroke, Model, MouseButton, MouseDownEvent, Pixels, @@ -357,7 +357,7 @@ impl TerminalView { } } - fn select_all(&mut self, _: &editor::SelectAll, cx: &mut ViewContext) { + fn select_all(&mut self, _: &editor::actions::SelectAll, cx: &mut ViewContext) { self.terminal.update(cx, |term, _| term.select_all()); cx.notify(); } diff --git a/crates/vim/src/command.rs b/crates/vim/src/command.rs index 34d8658afe..f1b4853feb 100644 --- a/crates/vim/src/command.rs +++ b/crates/vim/src/command.rs @@ -1,5 +1,5 @@ use command_palette::CommandInterceptResult; -use editor::{SortLinesCaseInsensitive, SortLinesCaseSensitive}; +use editor::actions::{SortLinesCaseInsensitive, SortLinesCaseSensitive}; use gpui::{impl_actions, Action, AppContext, ViewContext}; use serde_derive::Deserialize; use workspace::{SaveIntent, Workspace}; @@ -204,25 +204,31 @@ pub fn command_interceptor(mut query: &str, _: &AppContext) -> Option ("clist", diagnostics::Deploy.boxed_clone()), - "cc" => ("cc", editor::Hover.boxed_clone()), - "ll" => ("ll", editor::Hover.boxed_clone()), - "cn" | "cne" | "cnex" | "cnext" => ("cnext", editor::GoToDiagnostic.boxed_clone()), - "lne" | "lnex" | "lnext" => ("cnext", editor::GoToDiagnostic.boxed_clone()), + "cc" => ("cc", editor::actions::Hover.boxed_clone()), + "ll" => ("ll", editor::actions::Hover.boxed_clone()), + "cn" | "cne" | "cnex" | "cnext" => ("cnext", editor::actions::GoToDiagnostic.boxed_clone()), + "lne" | "lnex" | "lnext" => ("cnext", editor::actions::GoToDiagnostic.boxed_clone()), - "cpr" | "cpre" | "cprev" | "cprevi" | "cprevio" | "cpreviou" | "cprevious" => { - ("cprevious", editor::GoToPrevDiagnostic.boxed_clone()) + "cpr" | "cpre" | "cprev" | "cprevi" | "cprevio" | "cpreviou" | "cprevious" => ( + "cprevious", + editor::actions::GoToPrevDiagnostic.boxed_clone(), + ), + "cN" | "cNe" | "cNex" | "cNext" => { + ("cNext", editor::actions::GoToPrevDiagnostic.boxed_clone()) } - "cN" | "cNe" | "cNex" | "cNext" => ("cNext", editor::GoToPrevDiagnostic.boxed_clone()), - "lp" | "lpr" | "lpre" | "lprev" | "lprevi" | "lprevio" | "lpreviou" | "lprevious" => { - ("lprevious", editor::GoToPrevDiagnostic.boxed_clone()) + "lp" | "lpr" | "lpre" | "lprev" | "lprevi" | "lprevio" | "lpreviou" | "lprevious" => ( + "lprevious", + editor::actions::GoToPrevDiagnostic.boxed_clone(), + ), + "lN" | "lNe" | "lNex" | "lNext" => { + ("lNext", editor::actions::GoToPrevDiagnostic.boxed_clone()) } - "lN" | "lNe" | "lNex" | "lNext" => ("lNext", editor::GoToPrevDiagnostic.boxed_clone()), // modify the buffer (should accept [range]) "j" | "jo" | "joi" | "join" => ("join", JoinLines.boxed_clone()), "d" | "de" | "del" | "dele" | "delet" | "delete" | "dl" | "dell" | "delel" | "deletl" | "deletel" | "dp" | "dep" | "delp" | "delep" | "deletp" | "deletep" => { - ("delete", editor::DeleteLine.boxed_clone()) + ("delete", editor::actions::DeleteLine.boxed_clone()) } "sor" | "sor " | "sort" | "sort " => ("sort", SortLinesCaseSensitive.boxed_clone()), "sor i" | "sort i" => ("sort i", SortLinesCaseInsensitive.boxed_clone()), diff --git a/crates/vim/src/insert.rs b/crates/vim/src/insert.rs index 7c27231828..a063d37475 100644 --- a/crates/vim/src/insert.rs +++ b/crates/vim/src/insert.rs @@ -1,5 +1,5 @@ use crate::{normal::repeat, state::Mode, Vim}; -use editor::{scroll::autoscroll::Autoscroll, Bias}; +use editor::{scroll::Autoscroll, Bias}; use gpui::{actions, Action, ViewContext}; use language::SelectionGoal; use workspace::Workspace; diff --git a/crates/vim/src/motion.rs b/crates/vim/src/motion.rs index 73ba70d5ad..6215e4c16c 100644 --- a/crates/vim/src/motion.rs +++ b/crates/vim/src/motion.rs @@ -1,11 +1,10 @@ use editor::{ - char_kind, display_map::{DisplaySnapshot, FoldPoint, ToDisplayPoint}, movement::{self, find_boundary, find_preceding_boundary, FindRange, TextLayoutDetails}, - Bias, CharKind, DisplayPoint, ToOffset, + Bias, DisplayPoint, ToOffset, }; use gpui::{actions, impl_actions, px, ViewContext, WindowContext}; -use language::{Point, Selection, SelectionGoal}; +use language::{char_kind, CharKind, Point, Selection, SelectionGoal}; use serde::Deserialize; use workspace::Workspace; diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index a8f2e5fa5a..c21f54f2d3 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -18,7 +18,7 @@ use crate::{ Vim, }; use collections::HashSet; -use editor::scroll::autoscroll::Autoscroll; +use editor::scroll::Autoscroll; use editor::{Bias, DisplayPoint}; use gpui::{actions, ViewContext, WindowContext}; use language::SelectionGoal; diff --git a/crates/vim/src/normal/case.rs b/crates/vim/src/normal/case.rs index 22d09f8359..d94454891f 100644 --- a/crates/vim/src/normal/case.rs +++ b/crates/vim/src/normal/case.rs @@ -1,4 +1,4 @@ -use editor::scroll::autoscroll::Autoscroll; +use editor::scroll::Autoscroll; use gpui::ViewContext; use language::{Bias, Point}; use workspace::Workspace; diff --git a/crates/vim/src/normal/change.rs b/crates/vim/src/normal/change.rs index bf2a25a98d..86b7703846 100644 --- a/crates/vim/src/normal/change.rs +++ b/crates/vim/src/normal/change.rs @@ -1,13 +1,12 @@ use crate::{motion::Motion, object::Object, state::Mode, utils::copy_selections_content, Vim}; use editor::{ - char_kind, display_map::DisplaySnapshot, movement::{self, FindRange, TextLayoutDetails}, - scroll::autoscroll::Autoscroll, - CharKind, DisplayPoint, + scroll::Autoscroll, + DisplayPoint, }; use gpui::WindowContext; -use language::Selection; +use language::{char_kind, CharKind, Selection}; pub fn change_motion(vim: &mut Vim, motion: Motion, times: Option, cx: &mut WindowContext) { // Some motions ignore failure when switching to normal mode diff --git a/crates/vim/src/normal/delete.rs b/crates/vim/src/normal/delete.rs index b8105aeb8d..ed9cdf19fa 100644 --- a/crates/vim/src/normal/delete.rs +++ b/crates/vim/src/normal/delete.rs @@ -1,6 +1,6 @@ use crate::{motion::Motion, object::Object, utils::copy_selections_content, Vim}; use collections::{HashMap, HashSet}; -use editor::{display_map::ToDisplayPoint, scroll::autoscroll::Autoscroll, Bias}; +use editor::{display_map::ToDisplayPoint, scroll::Autoscroll, Bias}; use gpui::WindowContext; use language::Point; diff --git a/crates/vim/src/normal/increment.rs b/crates/vim/src/normal/increment.rs index 9fa06c4851..6353a881ed 100644 --- a/crates/vim/src/normal/increment.rs +++ b/crates/vim/src/normal/increment.rs @@ -1,6 +1,6 @@ use std::ops::Range; -use editor::{scroll::autoscroll::Autoscroll, MultiBufferSnapshot, ToOffset, ToPoint}; +use editor::{scroll::Autoscroll, MultiBufferSnapshot, ToOffset, ToPoint}; use gpui::{impl_actions, ViewContext, WindowContext}; use language::{Bias, Point}; use serde::Deserialize; diff --git a/crates/vim/src/normal/paste.rs b/crates/vim/src/normal/paste.rs index 169c2c4728..a65a816654 100644 --- a/crates/vim/src/normal/paste.rs +++ b/crates/vim/src/normal/paste.rs @@ -1,8 +1,7 @@ use std::{borrow::Cow, cmp}; use editor::{ - display_map::ToDisplayPoint, movement, scroll::autoscroll::Autoscroll, ClipboardSelection, - DisplayPoint, + display_map::ToDisplayPoint, movement, scroll::Autoscroll, ClipboardSelection, DisplayPoint, }; use gpui::{impl_actions, ViewContext}; use language::{Bias, SelectionGoal}; diff --git a/crates/vim/src/normal/repeat.rs b/crates/vim/src/normal/repeat.rs index a643c126ef..c6d1f0e6c3 100644 --- a/crates/vim/src/normal/repeat.rs +++ b/crates/vim/src/normal/repeat.rs @@ -12,7 +12,7 @@ actions!(vim, [Repeat, EndRepeat]); fn should_replay(action: &Box) -> bool { // skip so that we don't leave the character palette open - if editor::ShowCharacterPalette.partial_eq(&**action) { + if editor::actions::ShowCharacterPalette.partial_eq(&**action) { return false; } true diff --git a/crates/vim/src/normal/scroll.rs b/crates/vim/src/normal/scroll.rs index 84a27e20ce..8c06158231 100644 --- a/crates/vim/src/normal/scroll.rs +++ b/crates/vim/src/normal/scroll.rs @@ -1,7 +1,7 @@ use crate::Vim; use editor::{ display_map::ToDisplayPoint, - scroll::{scroll_amount::ScrollAmount, VERTICAL_SCROLL_MARGIN}, + scroll::{ScrollAmount, VERTICAL_SCROLL_MARGIN}, DisplayPoint, Editor, }; use gpui::{actions, ViewContext}; diff --git a/crates/vim/src/object.rs b/crates/vim/src/object.rs index 47d1647dc7..1e9361618c 100644 --- a/crates/vim/src/object.rs +++ b/crates/vim/src/object.rs @@ -1,13 +1,12 @@ use std::ops::Range; use editor::{ - char_kind, display_map::{DisplaySnapshot, ToDisplayPoint}, movement::{self, FindRange}, - Bias, CharKind, DisplayPoint, + Bias, DisplayPoint, }; use gpui::{actions, impl_actions, ViewContext, WindowContext}; -use language::Selection; +use language::{char_kind, CharKind, Selection}; use serde::Deserialize; use workspace::Workspace; diff --git a/crates/vim/src/visual.rs b/crates/vim/src/visual.rs index 1fd11167c6..797a271574 100644 --- a/crates/vim/src/visual.rs +++ b/crates/vim/src/visual.rs @@ -5,7 +5,7 @@ use collections::HashMap; use editor::{ display_map::{DisplaySnapshot, ToDisplayPoint}, movement, - scroll::autoscroll::Autoscroll, + scroll::Autoscroll, Bias, DisplayPoint, Editor, }; use gpui::{actions, ViewContext, WindowContext}; diff --git a/crates/zed/src/app_menus.rs b/crates/zed/src/app_menus.rs index 2aff05d884..fc063a620f 100644 --- a/crates/zed/src/app_menus.rs +++ b/crates/zed/src/app_menus.rs @@ -53,39 +53,46 @@ pub fn app_menus() -> Vec> { Menu { name: "Edit", items: vec![ - MenuItem::os_action("Undo", editor::Undo, OsAction::Undo), - MenuItem::os_action("Redo", editor::Redo, OsAction::Redo), + MenuItem::os_action("Undo", editor::actions::Undo, OsAction::Undo), + MenuItem::os_action("Redo", editor::actions::Redo, OsAction::Redo), MenuItem::separator(), - MenuItem::os_action("Cut", editor::Cut, OsAction::Cut), - MenuItem::os_action("Copy", editor::Copy, OsAction::Copy), - MenuItem::os_action("Paste", editor::Paste, OsAction::Paste), + MenuItem::os_action("Cut", editor::actions::Cut, OsAction::Cut), + MenuItem::os_action("Copy", editor::actions::Copy, OsAction::Copy), + MenuItem::os_action("Paste", editor::actions::Paste, OsAction::Paste), MenuItem::separator(), MenuItem::action("Find", search::buffer_search::Deploy { focus: true }), MenuItem::action("Find In Project", workspace::NewSearch), MenuItem::separator(), - MenuItem::action("Toggle Line Comment", editor::ToggleComments::default()), - MenuItem::action("Emoji & Symbols", editor::ShowCharacterPalette), + MenuItem::action( + "Toggle Line Comment", + editor::actions::ToggleComments::default(), + ), + MenuItem::action("Emoji & Symbols", editor::actions::ShowCharacterPalette), ], }, Menu { name: "Selection", items: vec![ - MenuItem::os_action("Select All", editor::SelectAll, OsAction::SelectAll), - MenuItem::action("Expand Selection", editor::SelectLargerSyntaxNode), - MenuItem::action("Shrink Selection", editor::SelectSmallerSyntaxNode), + MenuItem::os_action( + "Select All", + editor::actions::SelectAll, + OsAction::SelectAll, + ), + MenuItem::action("Expand Selection", editor::actions::SelectLargerSyntaxNode), + MenuItem::action("Shrink Selection", editor::actions::SelectSmallerSyntaxNode), MenuItem::separator(), - MenuItem::action("Add Cursor Above", editor::AddSelectionAbove), - MenuItem::action("Add Cursor Below", editor::AddSelectionBelow), + MenuItem::action("Add Cursor Above", editor::actions::AddSelectionAbove), + MenuItem::action("Add Cursor Below", editor::actions::AddSelectionBelow), MenuItem::action( "Select Next Occurrence", - editor::SelectNext { + editor::actions::SelectNext { replace_newest: false, }, ), MenuItem::separator(), - MenuItem::action("Move Line Up", editor::MoveLineUp), - MenuItem::action("Move Line Down", editor::MoveLineDown), - MenuItem::action("Duplicate Selection", editor::DuplicateLine), + MenuItem::action("Move Line Up", editor::actions::MoveLineUp), + MenuItem::action("Move Line Down", editor::actions::MoveLineDown), + MenuItem::action("Duplicate Selection", editor::actions::DuplicateLine), ], }, Menu { @@ -124,13 +131,13 @@ pub fn app_menus() -> Vec> { MenuItem::action("Go to File", file_finder::Toggle), // MenuItem::action("Go to Symbol in Project", project_symbols::Toggle), MenuItem::action("Go to Symbol in Editor", outline::Toggle), - MenuItem::action("Go to Definition", editor::GoToDefinition), - MenuItem::action("Go to Type Definition", editor::GoToTypeDefinition), - MenuItem::action("Find All References", editor::FindAllReferences), + MenuItem::action("Go to Definition", editor::actions::GoToDefinition), + MenuItem::action("Go to Type Definition", editor::actions::GoToTypeDefinition), + MenuItem::action("Find All References", editor::actions::FindAllReferences), MenuItem::action("Go to Line/Column", go_to_line::Toggle), MenuItem::separator(), - MenuItem::action("Next Problem", editor::GoToDiagnostic), - MenuItem::action("Previous Problem", editor::GoToPrevDiagnostic), + MenuItem::action("Next Problem", editor::actions::GoToDiagnostic), + MenuItem::action("Previous Problem", editor::actions::GoToPrevDiagnostic), ], }, Menu { diff --git a/crates/zed/src/open_listener.rs b/crates/zed/src/open_listener.rs index 6db020a785..f3a10208d0 100644 --- a/crates/zed/src/open_listener.rs +++ b/crates/zed/src/open_listener.rs @@ -1,7 +1,7 @@ use anyhow::{anyhow, Context, Result}; use cli::{ipc, IpcHandshake}; use cli::{ipc::IpcSender, CliRequest, CliResponse}; -use editor::scroll::autoscroll::Autoscroll; +use editor::scroll::Autoscroll; use editor::Editor; use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender}; use futures::channel::{mpsc, oneshot}; diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index afc06ad193..112c219d2d 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -730,7 +730,7 @@ fn open_bundled_file( mod tests { use super::*; use assets::Assets; - use editor::{scroll::autoscroll::Autoscroll, DisplayPoint, Editor, EditorEvent}; + use editor::{scroll::Autoscroll, DisplayPoint, Editor, EditorEvent}; use gpui::{ actions, Action, AnyWindowHandle, AppContext, AssetSource, Entity, TestAppContext, VisualTestContext, WindowHandle,