1//! This module contains all actions supported by [`Editor`].
2use super::*;
3use gpui::action_as;
4use util::serde::default_true;
5
6#[derive(PartialEq, Clone, Deserialize, Default)]
7pub struct SelectNext {
8 #[serde(default)]
9 pub replace_newest: bool,
10}
11
12#[derive(PartialEq, Clone, Deserialize, Default)]
13pub struct SelectPrevious {
14 #[serde(default)]
15 pub replace_newest: bool,
16}
17
18#[derive(PartialEq, Clone, Deserialize, Default)]
19pub struct MoveToBeginningOfLine {
20 #[serde(default = "default_true")]
21 pub(super) stop_at_soft_wraps: bool,
22}
23
24#[derive(PartialEq, Clone, Deserialize, Default)]
25pub struct SelectToBeginningOfLine {
26 #[serde(default)]
27 pub(super) stop_at_soft_wraps: bool,
28}
29
30#[derive(PartialEq, Clone, Deserialize, Default)]
31pub struct MovePageUp {
32 #[serde(default)]
33 pub(super) center_cursor: bool,
34}
35
36#[derive(PartialEq, Clone, Deserialize, Default)]
37pub struct MovePageDown {
38 #[serde(default)]
39 pub(super) center_cursor: bool,
40}
41
42#[derive(PartialEq, Clone, Deserialize, Default)]
43pub struct MoveToEndOfLine {
44 #[serde(default = "default_true")]
45 pub stop_at_soft_wraps: bool,
46}
47
48#[derive(PartialEq, Clone, Deserialize, Default)]
49pub struct SelectToEndOfLine {
50 #[serde(default)]
51 pub(super) stop_at_soft_wraps: bool,
52}
53
54#[derive(PartialEq, Clone, Deserialize, Default)]
55pub struct ToggleCodeActions {
56 // Display row from which the action was deployed.
57 #[serde(default)]
58 pub deployed_from_indicator: Option<DisplayRow>,
59}
60
61#[derive(PartialEq, Clone, Deserialize, Default)]
62pub struct ConfirmCompletion {
63 #[serde(default)]
64 pub item_ix: Option<usize>,
65}
66
67#[derive(PartialEq, Clone, Deserialize, Default)]
68pub struct ComposeCompletion {
69 #[serde(default)]
70 pub item_ix: Option<usize>,
71}
72
73#[derive(PartialEq, Clone, Deserialize, Default)]
74pub struct ConfirmCodeAction {
75 #[serde(default)]
76 pub item_ix: Option<usize>,
77}
78
79#[derive(PartialEq, Clone, Deserialize, Default)]
80pub struct ToggleComments {
81 #[serde(default)]
82 pub advance_downwards: bool,
83}
84
85#[derive(PartialEq, Clone, Deserialize, Default)]
86pub struct FoldAt {
87 pub buffer_row: MultiBufferRow,
88}
89
90#[derive(PartialEq, Clone, Deserialize, Default)]
91pub struct UnfoldAt {
92 pub buffer_row: MultiBufferRow,
93}
94
95#[derive(PartialEq, Clone, Deserialize, Default)]
96pub struct MoveUpByLines {
97 #[serde(default)]
98 pub(super) lines: u32,
99}
100
101#[derive(PartialEq, Clone, Deserialize, Default)]
102pub struct MoveDownByLines {
103 #[serde(default)]
104 pub(super) lines: u32,
105}
106#[derive(PartialEq, Clone, Deserialize, Default)]
107pub struct SelectUpByLines {
108 #[serde(default)]
109 pub(super) lines: u32,
110}
111
112#[derive(PartialEq, Clone, Deserialize, Default)]
113pub struct SelectDownByLines {
114 #[serde(default)]
115 pub(super) lines: u32,
116}
117
118#[derive(PartialEq, Clone, Deserialize, Default)]
119pub struct ExpandExcerpts {
120 #[serde(default)]
121 pub(super) lines: u32,
122}
123
124#[derive(PartialEq, Clone, Deserialize, Default)]
125pub struct ExpandExcerptsUp {
126 #[serde(default)]
127 pub(super) lines: u32,
128}
129
130#[derive(PartialEq, Clone, Deserialize, Default)]
131pub struct ExpandExcerptsDown {
132 #[serde(default)]
133 pub(super) lines: u32,
134}
135#[derive(PartialEq, Clone, Deserialize, Default)]
136pub struct ShowCompletions {
137 #[serde(default)]
138 pub(super) trigger: Option<String>,
139}
140
141#[derive(PartialEq, Clone, Deserialize, Default)]
142pub struct HandleInput(pub String);
143
144#[derive(PartialEq, Clone, Deserialize, Default)]
145pub struct DeleteToNextWordEnd {
146 #[serde(default)]
147 pub ignore_newlines: bool,
148}
149
150#[derive(PartialEq, Clone, Deserialize, Default)]
151pub struct DeleteToPreviousWordStart {
152 #[serde(default)]
153 pub ignore_newlines: bool,
154}
155
156impl_actions!(
157 editor,
158 [
159 ComposeCompletion,
160 ConfirmCodeAction,
161 ConfirmCompletion,
162 DeleteToNextWordEnd,
163 DeleteToPreviousWordStart,
164 ExpandExcerpts,
165 ExpandExcerptsDown,
166 ExpandExcerptsUp,
167 FoldAt,
168 HandleInput,
169 MoveDownByLines,
170 MovePageDown,
171 MovePageUp,
172 MoveToBeginningOfLine,
173 MoveToEndOfLine,
174 MoveUpByLines,
175 SelectDownByLines,
176 SelectNext,
177 SelectPrevious,
178 SelectToBeginningOfLine,
179 SelectToEndOfLine,
180 SelectUpByLines,
181 ShowCompletions,
182 ToggleCodeActions,
183 ToggleComments,
184 UnfoldAt,
185 ]
186);
187
188gpui::actions!(
189 editor,
190 [
191 AcceptInlineCompletion,
192 AcceptPartialCopilotSuggestion,
193 AcceptPartialInlineCompletion,
194 AddSelectionAbove,
195 AddSelectionBelow,
196 ApplyDiffHunk,
197 Backspace,
198 Cancel,
199 CancelLanguageServerWork,
200 ConfirmRename,
201 ContextMenuFirst,
202 ContextMenuLast,
203 ContextMenuNext,
204 ContextMenuPrev,
205 ConvertToKebabCase,
206 ConvertToLowerCamelCase,
207 ConvertToLowerCase,
208 ConvertToOppositeCase,
209 ConvertToSnakeCase,
210 ConvertToTitleCase,
211 ConvertToUpperCamelCase,
212 ConvertToUpperCase,
213 Copy,
214 CopyFileLocation,
215 CopyHighlightJson,
216 CopyPath,
217 CopyPermalinkToLine,
218 CopyRelativePath,
219 Cut,
220 CutToEndOfLine,
221 Delete,
222 DeleteLine,
223 DeleteToBeginningOfLine,
224 DeleteToEndOfLine,
225 DeleteToNextSubwordEnd,
226 DeleteToPreviousSubwordStart,
227 DisplayCursorNames,
228 DuplicateLineDown,
229 DuplicateLineUp,
230 ExpandAllHunkDiffs,
231 ExpandMacroRecursively,
232 FindAllReferences,
233 Fold,
234 FoldAll,
235 FoldRecursive,
236 FoldSelectedRanges,
237 ToggleFold,
238 ToggleFoldRecursive,
239 Format,
240 FormatSelections,
241 GoToDeclaration,
242 GoToDeclarationSplit,
243 GoToDefinition,
244 GoToDefinitionSplit,
245 GoToDiagnostic,
246 GoToHunk,
247 GoToImplementation,
248 GoToImplementationSplit,
249 GoToPrevDiagnostic,
250 GoToPrevHunk,
251 GoToTypeDefinition,
252 GoToTypeDefinitionSplit,
253 HalfPageDown,
254 HalfPageUp,
255 Hover,
256 Indent,
257 JoinLines,
258 LineDown,
259 LineUp,
260 MoveDown,
261 MoveLeft,
262 MoveLineDown,
263 MoveLineUp,
264 MoveRight,
265 MoveToBeginning,
266 MoveToEnclosingBracket,
267 MoveToEnd,
268 MoveToEndOfParagraph,
269 MoveToNextSubwordEnd,
270 MoveToNextWordEnd,
271 MoveToPreviousSubwordStart,
272 MoveToPreviousWordStart,
273 MoveToStartOfParagraph,
274 MoveUp,
275 Newline,
276 NewlineAbove,
277 NewlineBelow,
278 NextInlineCompletion,
279 NextScreen,
280 OpenExcerpts,
281 OpenExcerptsSplit,
282 OpenProposedChangesEditor,
283 OpenFile,
284 OpenPermalinkToLine,
285 OpenUrl,
286 Outdent,
287 PageDown,
288 PageUp,
289 Paste,
290 PreviousInlineCompletion,
291 Redo,
292 RedoSelection,
293 Rename,
294 RestartLanguageServer,
295 RevealInFileManager,
296 ReverseLines,
297 RevertFile,
298 ReloadFile,
299 RevertSelectedHunks,
300 Rewrap,
301 ScrollCursorBottom,
302 ScrollCursorCenter,
303 ScrollCursorCenterTopBottom,
304 ScrollCursorTop,
305 SelectAll,
306 SelectAllMatches,
307 SelectDown,
308 SelectEnclosingSymbol,
309 SelectLargerSyntaxNode,
310 SelectLeft,
311 SelectLine,
312 SelectPageDown,
313 SelectPageUp,
314 SelectRight,
315 SelectSmallerSyntaxNode,
316 SelectToBeginning,
317 SelectToEnd,
318 SelectToEndOfParagraph,
319 SelectToNextSubwordEnd,
320 SelectToNextWordEnd,
321 SelectToPreviousSubwordStart,
322 SelectToPreviousWordStart,
323 SelectToStartOfParagraph,
324 SelectUp,
325 ShowCharacterPalette,
326 ShowInlineCompletion,
327 ShowSignatureHelp,
328 ShuffleLines,
329 SortLinesCaseInsensitive,
330 SortLinesCaseSensitive,
331 SplitSelectionIntoLines,
332 SwitchSourceHeader,
333 Tab,
334 TabPrev,
335 ToggleAutoSignatureHelp,
336 ToggleGitBlame,
337 ToggleGitBlameInline,
338 ToggleHunkDiff,
339 ToggleIndentGuides,
340 ToggleInlayHints,
341 ToggleInlineCompletions,
342 ToggleLineNumbers,
343 ToggleRelativeLineNumbers,
344 ToggleSelectionMenu,
345 ToggleSoftWrap,
346 ToggleTabBar,
347 Transpose,
348 Undo,
349 UndoSelection,
350 UnfoldAll,
351 UnfoldLines,
352 UnfoldRecursive,
353 UniqueLinesCaseInsensitive,
354 UniqueLinesCaseSensitive,
355 ]
356);
357
358action_as!(outline, ToggleOutline as Toggle);
359
360action_as!(go_to_line, ToggleGoToLine as Toggle);