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