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 ConvertIndentationToSpaces,
274 ConvertIndentationToTabs,
275 ConvertToKebabCase,
276 ConvertToLowerCamelCase,
277 ConvertToLowerCase,
278 ConvertToOppositeCase,
279 ConvertToSnakeCase,
280 ConvertToTitleCase,
281 ConvertToUpperCamelCase,
282 ConvertToUpperCase,
283 ConvertToRot13,
284 ConvertToRot47,
285 Copy,
286 CopyAndTrim,
287 CopyFileLocation,
288 CopyHighlightJson,
289 CopyFileName,
290 CopyFileNameWithoutExtension,
291 CopyPermalinkToLine,
292 Cut,
293 CutToEndOfLine,
294 Delete,
295 DeleteLine,
296 DeleteToEndOfLine,
297 DeleteToNextSubwordEnd,
298 DeleteToPreviousSubwordStart,
299 DisplayCursorNames,
300 DuplicateLineDown,
301 DuplicateLineUp,
302 DuplicateSelection,
303 #[action(deprecated_aliases = ["editor::ExpandAllHunkDiffs"])]
304 ExpandAllDiffHunks,
305 ExpandMacroRecursively,
306 FindAllReferences,
307 FindNextMatch,
308 FindPreviousMatch,
309 Fold,
310 FoldAll,
311 FoldFunctionBodies,
312 FoldRecursive,
313 FoldSelectedRanges,
314 ToggleFold,
315 ToggleFoldRecursive,
316 Format,
317 FormatSelections,
318 GoToDeclaration,
319 GoToDeclarationSplit,
320 GoToDefinition,
321 GoToDefinitionSplit,
322 GoToDiagnostic,
323 GoToHunk,
324 GoToPreviousHunk,
325 GoToImplementation,
326 GoToImplementationSplit,
327 GoToNextChange,
328 GoToParentModule,
329 GoToPreviousChange,
330 GoToPreviousDiagnostic,
331 GoToTypeDefinition,
332 GoToTypeDefinitionSplit,
333 HalfPageDown,
334 HalfPageUp,
335 Hover,
336 Indent,
337 InsertUuidV4,
338 InsertUuidV7,
339 JoinLines,
340 KillRingCut,
341 KillRingYank,
342 LineDown,
343 LineUp,
344 MoveDown,
345 MoveLeft,
346 MoveLineDown,
347 MoveLineUp,
348 MoveRight,
349 MoveToBeginning,
350 MoveToEnclosingBracket,
351 MoveToEnd,
352 MoveToEndOfParagraph,
353 MoveToNextSubwordEnd,
354 MoveToNextWordEnd,
355 MoveToPreviousSubwordStart,
356 MoveToPreviousWordStart,
357 MoveToStartOfParagraph,
358 MoveToStartOfExcerpt,
359 MoveToStartOfNextExcerpt,
360 MoveToEndOfExcerpt,
361 MoveToEndOfPreviousExcerpt,
362 MoveUp,
363 Newline,
364 NewlineAbove,
365 NewlineBelow,
366 NextEditPrediction,
367 NextScreen,
368 OpenContextMenu,
369 OpenExcerpts,
370 OpenExcerptsSplit,
371 OpenProposedChangesEditor,
372 OpenDocs,
373 OpenPermalinkToLine,
374 #[action(deprecated_aliases = ["editor::OpenFile"])]
375 OpenSelectedFilename,
376 OpenSelectionsInMultibuffer,
377 OpenUrl,
378 OrganizeImports,
379 Outdent,
380 AutoIndent,
381 PageDown,
382 PageUp,
383 Paste,
384 PreviousEditPrediction,
385 Redo,
386 RedoSelection,
387 Rename,
388 RestartLanguageServer,
389 RevealInFileManager,
390 ReverseLines,
391 RevertFile,
392 ReloadFile,
393 Rewrap,
394 RunFlycheck,
395 ScrollCursorBottom,
396 ScrollCursorCenter,
397 ScrollCursorCenterTopBottom,
398 ScrollCursorTop,
399 SelectAll,
400 SelectAllMatches,
401 SelectToStartOfExcerpt,
402 SelectToStartOfNextExcerpt,
403 SelectToEndOfExcerpt,
404 SelectToEndOfPreviousExcerpt,
405 SelectDown,
406 SelectEnclosingSymbol,
407 SelectLargerSyntaxNode,
408 SelectLeft,
409 SelectLine,
410 SelectPageDown,
411 SelectPageUp,
412 SelectRight,
413 SelectSmallerSyntaxNode,
414 SelectToBeginning,
415 SelectToEnd,
416 SelectToEndOfParagraph,
417 SelectToNextSubwordEnd,
418 SelectToNextWordEnd,
419 SelectToPreviousSubwordStart,
420 SelectToPreviousWordStart,
421 SelectToStartOfParagraph,
422 SelectUp,
423 ShowCharacterPalette,
424 ShowEditPrediction,
425 ShowSignatureHelp,
426 ShowWordCompletions,
427 ShuffleLines,
428 SortLinesCaseInsensitive,
429 SortLinesCaseSensitive,
430 SplitSelectionIntoLines,
431 StopLanguageServer,
432 SwitchSourceHeader,
433 Tab,
434 Backtab,
435 ToggleBreakpoint,
436 ToggleCase,
437 DisableBreakpoint,
438 EnableBreakpoint,
439 EditLogBreakpoint,
440 ToggleAutoSignatureHelp,
441 ToggleGitBlameInline,
442 OpenGitBlameCommit,
443 ToggleDiagnostics,
444 ToggleIndentGuides,
445 ToggleInlayHints,
446 ToggleInlineValues,
447 ToggleInlineDiagnostics,
448 ToggleEditPrediction,
449 ToggleLineNumbers,
450 ToggleMinimap,
451 SwapSelectionEnds,
452 SetMark,
453 ToggleRelativeLineNumbers,
454 #[action(deprecated_aliases = ["editor::ToggleHunkDiff"])]
455 ToggleSelectedDiffHunks,
456 ToggleSelectionMenu,
457 ToggleSoftWrap,
458 ToggleTabBar,
459 Transpose,
460 Undo,
461 UndoSelection,
462 UnfoldAll,
463 UnfoldLines,
464 UnfoldRecursive,
465 UniqueLinesCaseInsensitive,
466 UniqueLinesCaseSensitive,
467 ]
468);