From c267c7c9aaf39753fa1fc1e2d9528f40b99e92e8 Mon Sep 17 00:00:00 2001 From: Dmytro Maluka Date: Sat, 5 Jul 2025 16:09:55 +0200 Subject: [PATCH] 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. --- runtime/help/keybindings.md | 7 +++++++ runtime/help/plugins.md | 9 ++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/runtime/help/keybindings.md b/runtime/help/keybindings.md index af6072a8..5ed58570 100644 --- a/runtime/help/keybindings.md +++ b/runtime/help/keybindings.md @@ -70,6 +70,13 @@ will execute `InsertTab`. To use `,`, `|` or `&` in an action (as an argument to a command, for example), escape it with `\` or wrap it in single or double quotes. +If the action has an `onAction` lua callback, for example `onAutocomplete` (see +`> help plugins`), then the action is only considered successful if the action +itself succeeded *and* the callback returned true. If there are multiple +`onAction` callbacks for this action, registered by multiple plugins, then the +action is only considered successful if the action itself succeeded and all the +callbacks returned true. + ## Binding commands You can also bind a key to execute a command in command mode (see diff --git a/runtime/help/plugins.md b/runtime/help/plugins.md index 0411fcff..4a8b8a68 100644 --- a/runtime/help/plugins.md +++ b/runtime/help/plugins.md @@ -71,8 +71,10 @@ that micro defines: * `onAction(bufpane)`: runs when `Action` is triggered by the user, where `Action` is a bindable action (see `> help keybindings`). A bufpane - is passed as input and the function should return a boolean defining - whether the view should be relocated after this action is performed. + is passed as input. The function should return a boolean defining + whether the action was successful, which is used when the action is + chained with other actions (see `> help keybindings`) to determine whether + the next actions in the chain should be executed or not. * `preAction(bufpane)`: runs immediately before `Action` is triggered by the user. Returns a boolean which defines whether the action should @@ -101,9 +103,6 @@ within. This is almost always the current bufpane. All available actions are listed in the keybindings section of the help. -These functions should also return a boolean specifying whether the bufpane -should be relocated to the cursor or not after the action is complete. - ## Accessing micro functions Some of micro's internal information is exposed in the form of packages, which