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 MoveToStartOfExcerpt,
333 MoveToEndOfExcerpt,
334 MoveUp,
335 Newline,
336 NewlineAbove,
337 NewlineBelow,
338 NextEditPrediction,
339 NextScreen,
340 OpenContextMenu,
341 OpenExcerpts,
342 OpenExcerptsSplit,
343 OpenProposedChangesEditor,
344 OpenDocs,
345 OpenPermalinkToLine,
346 OpenSelectionsInMultibuffer,
347 OpenUrl,
348 Outdent,
349 AutoIndent,
350 PageDown,
351 PageUp,
352 Paste,
353 PreviousEditPrediction,
354 Redo,
355 RedoSelection,
356 Rename,
357 RestartLanguageServer,
358 RevealInFileManager,
359 ReverseLines,
360 RevertFile,
361 ReloadFile,
362 Rewrap,
363 ScrollCursorBottom,
364 ScrollCursorCenter,
365 ScrollCursorCenterTopBottom,
366 ScrollCursorTop,
367 SelectAll,
368 SelectAllMatches,
369 SelectToStartOfExcerpt,
370 SelectToEndOfExcerpt,
371 SelectDown,
372 SelectEnclosingSymbol,
373 SelectLargerSyntaxNode,
374 SelectLeft,
375 SelectLine,
376 SelectPageDown,
377 SelectPageUp,
378 SelectRight,
379 SelectSmallerSyntaxNode,
380 SelectToBeginning,
381 SelectToEnd,
382 SelectToEndOfParagraph,
383 SelectToNextSubwordEnd,
384 SelectToNextWordEnd,
385 SelectToPreviousSubwordStart,
386 SelectToPreviousWordStart,
387 SelectToStartOfParagraph,
388 SelectUp,
389 ShowCharacterPalette,
390 ShowEditPrediction,
391 ShowSignatureHelp,
392 ShuffleLines,
393 SortLinesCaseInsensitive,
394 SortLinesCaseSensitive,
395 SplitSelectionIntoLines,
396 SwitchSourceHeader,
397 Tab,
398 TabPrev,
399 ToggleAutoSignatureHelp,
400 ToggleGitBlame,
401 ToggleGitBlameInline,
402 ToggleIndentGuides,
403 ToggleInlayHints,
404 ToggleInlineDiagnostics,
405 ToggleEditPrediction,
406 ToggleLineNumbers,
407 SwapSelectionEnds,
408 SetMark,
409 ToggleRelativeLineNumbers,
410 ToggleSelectionMenu,
411 ToggleSoftWrap,
412 ToggleTabBar,
413 Transpose,
414 Undo,
415 UndoSelection,
416 UnfoldAll,
417 UnfoldLines,
418 UnfoldRecursive,
419 UniqueLinesCaseInsensitive,
420 UniqueLinesCaseSensitive,
421 ]
422);
423
424action_as!(go_to_line, ToggleGoToLine as Toggle);
425
426action_with_deprecated_aliases!(editor, OpenSelectedFilename, ["editor::OpenFile"]);
427action_with_deprecated_aliases!(editor, ToggleSelectedDiffHunks, ["editor::ToggleHunkDiff"]);