936 lines · 32.5 KB · Rust
RawDownload
//! This module contains all actions supported by [`Editor`].use super::*;use gpui::{Action, actions};use project::project_settings::GoToDiagnosticSeverityFilter;use schemars::JsonSchema;use util::serde::default_true; /// Selects the next occurrence of the current selection.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct SelectNext {    #[serde(default)]    pub replace_newest: bool,} /// Selects the previous occurrence of the current selection.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct SelectPrevious {    #[serde(default)]    pub replace_newest: bool,} /// Moves the cursor to the beginning of the current line.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct MoveToBeginningOfLine {    #[serde(default = "default_true")]    pub stop_at_soft_wraps: bool,    #[serde(default)]    pub stop_at_indent: bool,} /// Selects from the cursor to the beginning of the current line.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct SelectToBeginningOfLine {    #[serde(default)]    pub(super) stop_at_soft_wraps: bool,    #[serde(default)]    pub stop_at_indent: bool,} /// Deletes from the cursor to the beginning of the current line.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct DeleteToBeginningOfLine {    #[serde(default)]    pub(super) stop_at_indent: bool,} /// Moves the cursor up by one page.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct MovePageUp {    #[serde(default)]    pub(super) center_cursor: bool,} /// Moves the cursor down by one page.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct MovePageDown {    #[serde(default)]    pub(super) center_cursor: bool,} /// Moves the cursor to the end of the current line.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct MoveToEndOfLine {    #[serde(default = "default_true")]    pub stop_at_soft_wraps: bool,} /// Selects from the cursor to the end of the current line.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct SelectToEndOfLine {    #[serde(default)]    pub(super) stop_at_soft_wraps: bool,} /// Toggles the display of available code actions at the cursor position.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct ToggleCodeActions {    // Source from which the action was deployed.    #[serde(default)]    #[serde(skip)]    pub deployed_from: Option<CodeActionSource>,    // Run first available task if there is only one.    #[serde(default)]    #[serde(skip)]    pub quick_launch: bool,} #[derive(PartialEq, Clone, Debug)]pub enum CodeActionSource {    Indicator(DisplayRow),    RunMenu(DisplayRow),    QuickActionBar,} /// Confirms and accepts the currently selected completion suggestion.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct ConfirmCompletion {    #[serde(default)]    pub item_ix: Option<usize>,} /// Composes multiple completion suggestions into a single completion.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct ComposeCompletion {    #[serde(default)]    pub item_ix: Option<usize>,} /// Confirms and applies the currently selected code action.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct ConfirmCodeAction {    #[serde(default)]    pub item_ix: Option<usize>,} /// Toggles comment markers for the selected lines.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct ToggleComments {    #[serde(default)]    pub advance_downwards: bool,    #[serde(default)]    pub ignore_indent: bool,} /// Moves the cursor up by a specified number of lines.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct MoveUpByLines {    #[serde(default)]    pub(super) lines: u32,} /// Moves the cursor down by a specified number of lines.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct MoveDownByLines {    #[serde(default)]    pub(super) lines: u32,} /// Extends selection up by a specified number of lines.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct SelectUpByLines {    #[serde(default)]    pub(super) lines: u32,} /// Extends selection down by a specified number of lines.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct SelectDownByLines {    #[serde(default)]    pub(super) lines: u32,} /// Expands all excerpts in the editor.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct ExpandExcerpts {    #[serde(default)]    pub(super) lines: u32,} /// Expands excerpts above the current position.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct ExpandExcerptsUp {    #[serde(default)]    pub(super) lines: u32,} /// Expands excerpts below the current position.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct ExpandExcerptsDown {    #[serde(default)]    pub(super) lines: u32,} /// Handles text input in the editor.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]pub struct HandleInput(pub String); /// Deletes from the cursor to the end of the next word./// Stops before the end of the next word, if whitespace sequences of length >= 2 are encountered.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct DeleteToNextWordEnd {    #[serde(default)]    pub ignore_newlines: bool,    // Whether to stop before the end of the next word, if language-defined bracket is encountered.    #[serde(default)]    pub ignore_brackets: bool,} /// Deletes from the cursor to the start of the previous word./// Stops before the start of the previous word, if whitespace sequences of length >= 2 are encountered.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct DeleteToPreviousWordStart {    #[serde(default)]    pub ignore_newlines: bool,    // Whether to stop before the start of the previous word, if language-defined bracket is encountered.    #[serde(default)]    pub ignore_brackets: bool,} /// Deletes from the cursor to the end of the next subword./// Stops before the end of the next subword, if whitespace sequences of length >= 2 are encountered.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct DeleteToNextSubwordEnd {    #[serde(default)]    pub ignore_newlines: bool,    // Whether to stop before the start of the previous word, if language-defined bracket is encountered.    #[serde(default)]    pub ignore_brackets: bool,} /// Deletes from the cursor to the start of the previous subword./// Stops before the start of the previous subword, if whitespace sequences of length >= 2 are encountered.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct DeleteToPreviousSubwordStart {    #[serde(default)]    pub ignore_newlines: bool,    // Whether to stop before the start of the previous word, if language-defined bracket is encountered.    #[serde(default)]    pub ignore_brackets: bool,} /// Cuts from cursor to end of line.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct CutToEndOfLine {    #[serde(default)]    pub stop_at_newlines: bool,} /// Folds all code blocks at the specified indentation level.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]pub struct FoldAtLevel(pub u32); /// Spawns the nearest available task from the current cursor position.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct SpawnNearestTask {    #[serde(default)]    pub reveal: task::RevealStrategy,} #[derive(Clone, PartialEq, Action)]#[action(no_json, no_register)]pub struct DiffClipboardWithSelectionData {    pub clipboard_text: String,    pub editor: Entity<Editor>,} #[derive(Debug, PartialEq, Eq, Clone, Copy, Deserialize, Default)]pub enum UuidVersion {    #[default]    V4,    V7,} /// Splits selection into individual lines.#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct SplitSelectionIntoLines {    /// Keep the text selected after splitting instead of collapsing to cursors.    #[serde(default)]    pub keep_selections: bool,} /// Goes to the next diagnostic in the file.#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct GoToDiagnostic {    #[serde(default)]    pub severity: GoToDiagnosticSeverityFilter,} /// Goes to the previous diagnostic in the file.#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct GoToPreviousDiagnostic {    #[serde(default)]    pub severity: GoToDiagnosticSeverityFilter,} /// Adds a cursor above the current selection.#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct AddSelectionAbove {    #[serde(default = "default_true")]    pub skip_soft_wrap: bool,} /// Adds a cursor below the current selection.#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct AddSelectionBelow {    #[serde(default = "default_true")]    pub skip_soft_wrap: bool,} /// Inserts a snippet at the cursor.#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]#[action(namespace = editor)]#[serde(deny_unknown_fields)]pub struct InsertSnippet {    /// Language name if using a named snippet, or `None` for a global snippet    ///    /// This is typically lowercase and matches the filename containing the snippet, without the `.json` extension.    pub language: Option<String>,    /// Name if using a named snippet    pub name: Option<String>,     /// Snippet body, if not using a named snippet    // todo(andrew): use `ListOrDirect` or similar for multiline snippet body    pub snippet: Option<String>,} actions!(    debugger,    [        /// Runs program execution to the current cursor position.        RunToCursor,        /// Evaluates the selected text in the debugger context.        EvaluateSelectedText    ]); actions!(    go_to_line,    [        /// Toggles the go to line dialog.        #[action(name = "Toggle")]        ToggleGoToLine    ]); actions!(    editor,    [        /// Accepts the full edit prediction.        AcceptEditPrediction,        /// Accepts a partial edit prediction.        #[action(deprecated_aliases = ["editor::AcceptPartialCopilotSuggestion"])]        AcceptNextWordEditPrediction,        AcceptNextLineEditPrediction,        /// Applies all diff hunks in the editor.        ApplyAllDiffHunks,        /// Applies the diff hunk at the current position.        ApplyDiffHunk,        /// Deletes the character before the cursor.        Backspace,        /// Shows git blame information for the current line.        BlameHover,        /// Cancels the current operation.        Cancel,        /// Cancels the running flycheck operation.        CancelFlycheck,        /// Cancels pending language server work.        CancelLanguageServerWork,        /// Clears flycheck results.        ClearFlycheck,        /// Confirms the rename operation.        ConfirmRename,        /// Confirms completion by inserting at cursor.        ConfirmCompletionInsert,        /// Confirms completion by replacing existing text.        ConfirmCompletionReplace,        /// Navigates to the first item in the context menu.        ContextMenuFirst,        /// Navigates to the last item in the context menu.        ContextMenuLast,        /// Navigates to the next item in the context menu.        ContextMenuNext,        /// Navigates to the previous item in the context menu.        ContextMenuPrevious,        /// Converts indentation from tabs to spaces.        ConvertIndentationToSpaces,        /// Converts indentation from spaces to tabs.        ConvertIndentationToTabs,        /// Converts selected text to kebab-case.        ConvertToKebabCase,        /// Converts selected text to lowerCamelCase.        ConvertToLowerCamelCase,        /// Converts selected text to lowercase.        ConvertToLowerCase,        /// Toggles the case of selected text.        ConvertToOppositeCase,        /// Converts selected text to sentence case.        ConvertToSentenceCase,        /// Converts selected text to snake_case.        ConvertToSnakeCase,        /// Converts selected text to Title Case.        ConvertToTitleCase,        /// Converts selected text to UpperCamelCase.        ConvertToUpperCamelCase,        /// Converts selected text to UPPERCASE.        ConvertToUpperCase,        /// Applies ROT13 cipher to selected text.        ConvertToRot13,        /// Applies ROT47 cipher to selected text.        ConvertToRot47,        /// Copies selected text to the clipboard.        Copy,        /// Copies selected text to the clipboard with leading/trailing whitespace trimmed.        CopyAndTrim,        /// Copies the current file location to the clipboard.        CopyFileLocation,        /// Copies the highlighted text as JSON.        CopyHighlightJson,        /// Copies the current file name to the clipboard.        CopyFileName,        /// Copies the file name without extension to the clipboard.        CopyFileNameWithoutExtension,        /// Copies a permalink to the current line.        CopyPermalinkToLine,        /// Cuts selected text to the clipboard.        Cut,        /// Deletes the character after the cursor.        Delete,        /// Deletes the current line.        DeleteLine,        /// Deletes from cursor to end of line.        DeleteToEndOfLine,        /// Diffs the text stored in the clipboard against the current selection.        DiffClipboardWithSelection,        /// Displays names of all active cursors.        DisplayCursorNames,        /// Duplicates the current line below.        DuplicateLineDown,        /// Duplicates the current line above.        DuplicateLineUp,        /// Duplicates the current selection.        DuplicateSelection,        /// Expands all diff hunks in the editor.        #[action(deprecated_aliases = ["editor::ExpandAllHunkDiffs"])]        ExpandAllDiffHunks,        /// Collapses all diff hunks in the editor.        CollapseAllDiffHunks,        /// Expands macros recursively at cursor position.        ExpandMacroRecursively,        /// Finds the next match in the search.        FindNextMatch,        /// Finds the previous match in the search.        FindPreviousMatch,        /// Folds the current code block.

Lines 1–500 of 936.