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