aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/builtin.txt33
-rw-r--r--runtime/lua/vim/_meta/vimfn.lua21
-rw-r--r--src/nvim/eval.lua33
3 files changed, 48 insertions, 39 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 2ce66d8cc2..af7bcf4392 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -7374,28 +7374,31 @@ state([{what}]) *state()*
current state. Mostly useful in callbacks that want to do
work that may not always be safe. Roughly this works like:
- callback uses state() to check if work is safe to do.
- If yes, then do it right away.
- Otherwise add to work queue and add SafeState autocommand.
- - When SafeState is triggered, check with state() if the work
- can be done now, and if yes remove it from the queue and
- execute.
+ Yes: then do it right away.
+ No: add to work queue and add a |SafeState| autocommand.
+ - When SafeState is triggered and executes your autocommand,
+ check with `state()` if the work can be done now, and if yes
+ remove it from the queue and execute.
+ Remove the autocommand if the queue is now empty.
Also see |mode()|.
When {what} is given only characters in this string will be
added. E.g, this checks if the screen has scrolled: >vim
- if state('s') != ''
+ if state('s') == ''
+ " screen has not scrolled
These characters indicate the state, generally indicating that
something is busy:
- m halfway a mapping, :normal command, feedkeys() or
- stuffed command
- o operator pending or waiting for a command argument
- a Insert mode autocomplete active
- x executing an autocommand
- S not triggering SafeState
- c callback invoked, including timer (repeats for
- recursiveness up to "ccc")
- s screen has scrolled for messages
+ m halfway a mapping, :normal command, feedkeys() or
+ stuffed command
+ o operator pending or waiting for a command argument,
+ e.g. after |f|
+ a Insert mode autocomplete active
+ x executing an autocommand
+ S not triggering SafeState
+ c callback invoked, including timer (repeats for
+ recursiveness up to "ccc")
+ s screen has scrolled for messages
stdioopen({opts}) *stdioopen()*
With |--headless| this opens stdin and stdout as a |channel|.
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua
index 70d1aa4a79..86d3dd21a1 100644
--- a/runtime/lua/vim/_meta/vimfn.lua
+++ b/runtime/lua/vim/_meta/vimfn.lua
@@ -8749,27 +8749,30 @@ function vim.fn.srand(expr) end
--- current state. Mostly useful in callbacks that want to do
--- work that may not always be safe. Roughly this works like:
--- - callback uses state() to check if work is safe to do.
---- If yes, then do it right away.
---- Otherwise add to work queue and add SafeState autocommand.
---- - When SafeState is triggered, check with state() if the work
---- can be done now, and if yes remove it from the queue and
---- execute.
+--- Yes: then do it right away.
+--- No: add to work queue and add a |SafeState| autocommand.
+--- - When SafeState is triggered and executes your autocommand,
+--- check with `state()` if the work can be done now, and if yes
+--- remove it from the queue and execute.
+--- Remove the autocommand if the queue is now empty.
--- Also see |mode()|.
---
--- When {what} is given only characters in this string will be
--- added. E.g, this checks if the screen has scrolled: >vim
---- if state('s') != ''
+--- if state('s') == ''
+--- " screen has not scrolled
---
--- These characters indicate the state, generally indicating that
--- something is busy:
--- m halfway a mapping, :normal command, feedkeys() or
---- stuffed command
---- o operator pending or waiting for a command argument
+--- stuffed command
+--- o operator pending or waiting for a command argument,
+--- e.g. after |f|
--- a Insert mode autocomplete active
--- x executing an autocommand
--- S not triggering SafeState
--- c callback invoked, including timer (repeats for
---- recursiveness up to "ccc")
+--- recursiveness up to "ccc")
--- s screen has scrolled for messages
---
--- @param what? string
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index e786901c2f..544df33249 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -10460,28 +10460,31 @@ M.funcs = {
current state. Mostly useful in callbacks that want to do
work that may not always be safe. Roughly this works like:
- callback uses state() to check if work is safe to do.
- If yes, then do it right away.
- Otherwise add to work queue and add SafeState autocommand.
- - When SafeState is triggered, check with state() if the work
- can be done now, and if yes remove it from the queue and
- execute.
+ Yes: then do it right away.
+ No: add to work queue and add a |SafeState| autocommand.
+ - When SafeState is triggered and executes your autocommand,
+ check with `state()` if the work can be done now, and if yes
+ remove it from the queue and execute.
+ Remove the autocommand if the queue is now empty.
Also see |mode()|.
When {what} is given only characters in this string will be
added. E.g, this checks if the screen has scrolled: >vim
- if state('s') != ''
+ if state('s') == ''
+ " screen has not scrolled
These characters indicate the state, generally indicating that
something is busy:
- m halfway a mapping, :normal command, feedkeys() or
- stuffed command
- o operator pending or waiting for a command argument
- a Insert mode autocomplete active
- x executing an autocommand
- S not triggering SafeState
- c callback invoked, including timer (repeats for
- recursiveness up to "ccc")
- s screen has scrolled for messages
+ m halfway a mapping, :normal command, feedkeys() or
+ stuffed command
+ o operator pending or waiting for a command argument,
+ e.g. after |f|
+ a Insert mode autocomplete active
+ x executing an autocommand
+ S not triggering SafeState
+ c callback invoked, including timer (repeats for
+ recursiveness up to "ccc")
+ s screen has scrolled for messages
]=],
fast = true,
name = 'state',