actions.rs

  1//! This module contains all actions supported by [`Editor`].
  2use super::*;
  3use gpui::{Action, actions};
  4use schemars::JsonSchema;
  5use util::serde::default_true;
  6
  7#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
  8#[action(namespace = editor)]
  9#[serde(deny_unknown_fields)]
 10pub struct SelectNext {
 11    #[serde(default)]
 12    pub replace_newest: bool,
 13}
 14
 15#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
 16#[action(namespace = editor)]
 17#[serde(deny_unknown_fields)]
 18pub struct SelectPrevious {
 19    #[serde(default)]
 20    pub replace_newest: bool,
 21}
 22
 23#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
 24#[action(namespace = editor)]
 25#[serde(deny_unknown_fields)]
 26pub struct MoveToBeginningOfLine {
 27    #[serde(default = "default_true")]
 28    pub stop_at_soft_wraps: bool,
 29    #[serde(default)]
 30    pub stop_at_indent: bool,
 31}
 32
 33#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
 34#[action(namespace = editor)]
 35#[serde(deny_unknown_fields)]
 36pub struct SelectToBeginningOfLine {
 37    #[serde(default)]
 38    pub(super) stop_at_soft_wraps: bool,
 39    #[serde(default)]
 40    pub stop_at_indent: bool,
 41}
 42
 43#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
 44#[action(namespace = editor)]
 45#[serde(deny_unknown_fields)]
 46pub struct DeleteToBeginningOfLine {
 47    #[serde(default)]
 48    pub(super) stop_at_indent: bool,
 49}
 50
 51#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
 52#[action(namespace = editor)]
 53#[serde(deny_unknown_fields)]
 54pub struct MovePageUp {
 55    #[serde(default)]
 56    pub(super) center_cursor: bool,
 57}
 58
 59#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
 60#[action(namespace = editor)]
 61#[serde(deny_unknown_fields)]
 62pub struct MovePageDown {
 63    #[serde(default)]
 64    pub(super) center_cursor: bool,
 65}
 66
 67#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
 68#[action(namespace = editor)]
 69#[serde(deny_unknown_fields)]
 70pub struct MoveToEndOfLine {
 71    #[serde(default = "default_true")]
 72    pub stop_at_soft_wraps: bool,
 73}
 74
 75#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
 76#[action(namespace = editor)]
 77#[serde(deny_unknown_fields)]
 78pub struct SelectToEndOfLine {
 79    #[serde(default)]
 80    pub(super) stop_at_soft_wraps: bool,
 81}
 82
 83#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
 84#[action(namespace = editor)]
 85#[serde(deny_unknown_fields)]
 86pub struct ToggleCodeActions {
 87    // Source from which the action was deployed.
 88    #[serde(default)]
 89    #[serde(skip)]
 90    pub deployed_from: Option<CodeActionSource>,
 91    // Run first available task if there is only one.
 92    #[serde(default)]
 93    #[serde(skip)]
 94    pub quick_launch: bool,
 95}
 96
 97#[derive(PartialEq, Clone, Debug)]
 98pub enum CodeActionSource {
 99    Indicator(DisplayRow),
100    RunMenu(DisplayRow),
101    QuickActionBar,
102}
103
104#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
105#[action(namespace = editor)]
106#[serde(deny_unknown_fields)]
107pub struct ConfirmCompletion {
108    #[serde(default)]
109    pub item_ix: Option<usize>,
110}
111
112#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
113#[action(namespace = editor)]
114#[serde(deny_unknown_fields)]
115pub struct ComposeCompletion {
116    #[serde(default)]
117    pub item_ix: Option<usize>,
118}
119
120#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
121#[action(namespace = editor)]
122#[serde(deny_unknown_fields)]
123pub struct ConfirmCodeAction {
124    #[serde(default)]
125    pub item_ix: Option<usize>,
126}
127
128#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
129#[action(namespace = editor)]
130#[serde(deny_unknown_fields)]
131pub struct ToggleComments {
132    #[serde(default)]
133    pub advance_downwards: bool,
134    #[serde(default)]
135    pub ignore_indent: bool,
136}
137
138#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
139#[action(namespace = editor)]
140#[serde(deny_unknown_fields)]
141pub struct MoveUpByLines {
142    #[serde(default)]
143    pub(super) lines: u32,
144}
145
146#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
147#[action(namespace = editor)]
148#[serde(deny_unknown_fields)]
149pub struct MoveDownByLines {
150    #[serde(default)]
151    pub(super) lines: u32,
152}
153
154#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
155#[action(namespace = editor)]
156#[serde(deny_unknown_fields)]
157pub struct SelectUpByLines {
158    #[serde(default)]
159    pub(super) lines: u32,
160}
161
162#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
163#[action(namespace = editor)]
164#[serde(deny_unknown_fields)]
165pub struct SelectDownByLines {
166    #[serde(default)]
167    pub(super) lines: u32,
168}
169
170#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
171#[action(namespace = editor)]
172#[serde(deny_unknown_fields)]
173pub struct ExpandExcerpts {
174    #[serde(default)]
175    pub(super) lines: u32,
176}
177
178#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
179#[action(namespace = editor)]
180#[serde(deny_unknown_fields)]
181pub struct ExpandExcerptsUp {
182    #[serde(default)]
183    pub(super) lines: u32,
184}
185
186#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
187#[action(namespace = editor)]
188#[serde(deny_unknown_fields)]
189pub struct ExpandExcerptsDown {
190    #[serde(default)]
191    pub(super) lines: u32,
192}
193
194#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
195#[action(namespace = editor)]
196#[serde(deny_unknown_fields)]
197pub struct ShowCompletions {
198    #[serde(default)]
199    pub(super) trigger: Option<String>,
200}
201
202#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
203#[action(namespace = editor)]
204pub struct HandleInput(pub String);
205
206#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
207#[action(namespace = editor)]
208#[serde(deny_unknown_fields)]
209pub struct DeleteToNextWordEnd {
210    #[serde(default)]
211    pub ignore_newlines: bool,
212}
213
214#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
215#[action(namespace = editor)]
216#[serde(deny_unknown_fields)]
217pub struct DeleteToPreviousWordStart {
218    #[serde(default)]
219    pub ignore_newlines: bool,
220}
221
222#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
223#[action(namespace = editor)]
224pub struct FoldAtLevel(pub u32);
225
226#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
227#[action(namespace = editor)]
228#[serde(deny_unknown_fields)]
229pub struct SpawnNearestTask {
230    #[serde(default)]
231    pub reveal: task::RevealStrategy,
232}
233
234#[derive(Debug, PartialEq, Eq, Clone, Copy, Deserialize, Default)]
235pub enum UuidVersion {
236    #[default]
237    V4,
238    V7,
239}
240
241actions!(debugger, [RunToCursor, EvaluateSelectedText]);
242
243actions!(
244    go_to_line,
245    [
246        #[action(name = "Toggle")]
247        ToggleGoToLine
248    ]
249);
250
251actions!(
252    editor,
253    [
254        AcceptEditPrediction,
255        AcceptPartialCopilotSuggestion,
256        AcceptPartialEditPrediction,
257        AddSelectionAbove,
258        AddSelectionBelow,
259        ApplyAllDiffHunks,
260        ApplyDiffHunk,
261        Backspace,
262        Cancel,
263        CancelFlycheck,
264        CancelLanguageServerWork,
265        ClearFlycheck,
266        ConfirmRename,
267        ConfirmCompletionInsert,
268        ConfirmCompletionReplace,
269        ContextMenuFirst,
270        ContextMenuLast,
271        ContextMenuNext,
272        ContextMenuPrevious,
273        ConvertToKebabCase,
274        ConvertToLowerCamelCase,
275        ConvertToLowerCase,
276        ConvertToOppositeCase,
277        ConvertToSnakeCase,
278        ConvertToTitleCase,
279        ConvertToUpperCamelCase,
280        ConvertToUpperCase,
281        ConvertToRot13,
282        ConvertToRot47,
283        Copy,
284        CopyAndTrim,
285        CopyFileLocation,
286        CopyHighlightJson,
287        CopyFileName,
288        CopyFileNameWithoutExtension,
289        CopyPermalinkToLine,
290        Cut,
291        CutToEndOfLine,
292        Delete,
293        DeleteLine,
294        DeleteToEndOfLine,
295        DeleteToNextSubwordEnd,
296        DeleteToPreviousSubwordStart,
297        DisplayCursorNames,
298        DuplicateLineDown,
299        DuplicateLineUp,
300        DuplicateSelection,
301        #[action(deprecated_aliases = ["editor::ExpandAllHunkDiffs"])]
302        ExpandAllDiffHunks,
303        ExpandMacroRecursively,
304        FindAllReferences,
305        FindNextMatch,
306        FindPreviousMatch,
307        Fold,
308        FoldAll,
309        FoldFunctionBodies,
310        FoldRecursive,
311        FoldSelectedRanges,
312        ToggleFold,
313        ToggleFoldRecursive,
314        Format,
315        FormatSelections,
316        GoToDeclaration,
317        GoToDeclarationSplit,
318        GoToDefinition,
319        GoToDefinitionSplit,
320        GoToDiagnostic,
321        GoToHunk,
322        GoToPreviousHunk,
323        GoToImplementation,
324        GoToImplementationSplit,
325        GoToNextChange,
326        GoToParentModule,
327        GoToPreviousChange,
328        GoToPreviousDiagnostic,
329        GoToTypeDefinition,
330        GoToTypeDefinitionSplit,
331        HalfPageDown,
332        HalfPageUp,
333        Hover,
334        Indent,
335        InsertUuidV4,
336        InsertUuidV7,
337        JoinLines,
338        KillRingCut,
339        KillRingYank,
340        LineDown,
341        LineUp,
342        MoveDown,
343        MoveLeft,
344        MoveLineDown,
345        MoveLineUp,
346        MoveRight,
347        MoveToBeginning,
348        MoveToEnclosingBracket,
349        MoveToEnd,
350        MoveToEndOfParagraph,
351        MoveToNextSubwordEnd,
352        MoveToNextWordEnd,
353        MoveToPreviousSubwordStart,
354        MoveToPreviousWordStart,
355        MoveToStartOfParagraph,
356        MoveToStartOfExcerpt,
357        MoveToStartOfNextExcerpt,
358        MoveToEndOfExcerpt,
359        MoveToEndOfPreviousExcerpt,
360        MoveUp,
361        Newline,
362        NewlineAbove,
363        NewlineBelow,
364        NextEditPrediction,
365        NextScreen,
366        OpenContextMenu,
367        OpenExcerpts,
368        OpenExcerptsSplit,
369        OpenProposedChangesEditor,
370        OpenDocs,
371        OpenPermalinkToLine,
372        #[action(deprecated_aliases = ["editor::OpenFile"])]
373        OpenSelectedFilename,
374        OpenSelectionsInMultibuffer,
375        OpenUrl,
376        OrganizeImports,
377        Outdent,
378        AutoIndent,
379        PageDown,
380        PageUp,
381        Paste,
382        PreviousEditPrediction,
383        Redo,
384        RedoSelection,
385        Rename,
386        RestartLanguageServer,
387        RevealInFileManager,
388        ReverseLines,
389        RevertFile,
390        ReloadFile,
391        Rewrap,
392        RunFlycheck,
393        ScrollCursorBottom,
394        ScrollCursorCenter,
395        ScrollCursorCenterTopBottom,
396        ScrollCursorTop,
397        SelectAll,
398        SelectAllMatches,
399        SelectToStartOfExcerpt,
400        SelectToStartOfNextExcerpt,
401        SelectToEndOfExcerpt,
402        SelectToEndOfPreviousExcerpt,
403        SelectDown,
404        SelectEnclosingSymbol,
405        SelectLargerSyntaxNode,
406        SelectLeft,
407        SelectLine,
408        SelectPageDown,
409        SelectPageUp,
410        SelectRight,
411        SelectSmallerSyntaxNode,
412        SelectToBeginning,
413        SelectToEnd,
414        SelectToEndOfParagraph,
415        SelectToNextSubwordEnd,
416        SelectToNextWordEnd,
417        SelectToPreviousSubwordStart,
418        SelectToPreviousWordStart,
419        SelectToStartOfParagraph,
420        SelectUp,
421        ShowCharacterPalette,
422        ShowEditPrediction,
423        ShowSignatureHelp,
424        ShowWordCompletions,
425        ShuffleLines,
426        SortLinesCaseInsensitive,
427        SortLinesCaseSensitive,
428        SplitSelectionIntoLines,
429        StopLanguageServer,
430        SwitchSourceHeader,
431        Tab,
432        Backtab,
433        ToggleBreakpoint,
434        ToggleCase,
435        DisableBreakpoint,
436        EnableBreakpoint,
437        EditLogBreakpoint,
438        ToggleAutoSignatureHelp,
439        ToggleGitBlameInline,
440        OpenGitBlameCommit,
441        ToggleDiagnostics,
442        ToggleIndentGuides,
443        ToggleInlayHints,
444        ToggleInlineValues,
445        ToggleInlineDiagnostics,
446        ToggleEditPrediction,
447        ToggleLineNumbers,
448        ToggleMinimap,
449        SwapSelectionEnds,
450        SetMark,
451        ToggleRelativeLineNumbers,
452        #[action(deprecated_aliases = ["editor::ToggleHunkDiff"])]
453        ToggleSelectedDiffHunks,
454        ToggleSelectionMenu,
455        ToggleSoftWrap,
456        ToggleTabBar,
457        Transpose,
458        Undo,
459        UndoSelection,
460        UnfoldAll,
461        UnfoldLines,
462        UnfoldRecursive,
463        UniqueLinesCaseInsensitive,
464        UniqueLinesCaseSensitive,
465    ]
466);