Skip to content

Commit c267c7c

Browse files
committed
help: Update and correct documentation for onAction return value
The documentation says that the returned value of onAction callbacks is used for determining whether the view should be relocated, which has nothing to do with reality, this returned value is used for a completely different thing. So update the docs accordingly.
1 parent ffdd4b4 commit c267c7c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

runtime/help/keybindings.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ will execute `InsertTab`. To use `,`, `|` or `&` in an action (as an argument
7070
to a command, for example), escape it with `\` or wrap it in single or double
7171
quotes.
7272

73+
If the action has an `onAction` lua callback, for example `onAutocomplete` (see
74+
`> help plugins`), then the action is only considered successful if the action
75+
itself succeeded *and* the callback returned true. If there are multiple
76+
`onAction` callbacks for this action, registered by multiple plugins, then the
77+
action is only considered successful if the action itself succeeded and all the
78+
callbacks returned true.
79+
7380
## Binding commands
7481

7582
You can also bind a key to execute a command in command mode (see

runtime/help/plugins.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ that micro defines:
7171

7272
* `onAction(bufpane)`: runs when `Action` is triggered by the user, where
7373
`Action` is a bindable action (see `> help keybindings`). A bufpane
74-
is passed as input and the function should return a boolean defining
75-
whether the view should be relocated after this action is performed.
74+
is passed as input. The function should return a boolean defining
75+
whether the action was successful, which is used when the action is
76+
chained with other actions (see `> help keybindings`) to determine whether
77+
the next actions in the chain should be executed or not.
7678

7779
* `preAction(bufpane)`: runs immediately before `Action` is triggered
7880
by the user. Returns a boolean which defines whether the action should
@@ -101,9 +103,6 @@ within. This is almost always the current bufpane.
101103

102104
All available actions are listed in the keybindings section of the help.
103105

104-
These functions should also return a boolean specifying whether the bufpane
105-
should be relocated to the cursor or not after the action is complete.
106-
107106
## Accessing micro functions
108107

109108
Some of micro's internal information is exposed in the form of packages, which

0 commit comments

Comments
 (0)