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