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