Followup to #20883
Related: #18144
This patch changes the behavior of the default `vim.ui.input` when the user
aborts with `<C-c>`. Currently, it produces an error message + stack and causes
`on_confirm` to not be called. With this patch, `<C-c>` will cause `on_confirm`
to be called with `nil`, the same behavior as when the user aborts with `<Esc>`.
I can think of three good reasons why the behavior should be this way:
1. Easier for the user to understand** It's not intuitive for there to be two
ways to abort an input dialog that have _different_ outcomes. As a user,
I would expect any action that cancels the input to leave me in the same
state. As a plugin author, I see no value in having two possible outcomes for
aborting the input. I have to handle both cases, but I can't think of
a situation where I would want to treat one differently than the other.
2. Provides an API that can be overridden by other implementations** The current
contract of "throw an error upon `<C-c>`" cannot be replicated by async
implementations of `vim.ui.input`. If the callsite wants to handle the case
of the user hitting `<C-c>` they need to use `pcall(vim.ui.input, ...)`,
however an async implementation will instantly return and so there will be no
way for it to produce the same error-throwing behavior when the user inputs
`<C-c>`. This makes it impossible to be fully API-compatible with the
built-in `vim.ui.input`.
3. Provides a useful guarantee to the callsite** As a plugin author, I want the
guarantee that `on_confirm` will _always_ be called (only catastrophic errors
should prevent this). If I am in the middle of some async thread of logic,
I need some way to resume that logic after handing off control to
`vim.ui.input`. The only way to handle the `<C-c>` case is with `pcall`,
which as already mentioned, breaks down if you're using an alternative
implementation.
Problem: Shell command with just space gives strange error.
Solution: Skip white space at start of the argument. (Christian Brabandt,
Shane-XB-Qian, closesvim/vim#11515, closesvim/vim#11495)
4e7590ec00
Co-authored-by: shane.xb.qian <shane.qian@foxmail.com>
- If Nvim was just started, don't create a new tab.
- Name the buffer "health://".
- Use "help" syntax instead of "markdown". It fits better, and
eliminates various workarounds.
- Simplfy formatting, avoid visual noise.
- Don't print a "INFO" status, it is noisy.
- Drop the ":" after statuses, they are already UPPERCASE and highlighted.
Problem: Illegal memory access if popup menu items are changed while the
menu is visible. (Tomáš Janoušek)
Solution: Make a copy of the text. (closesvim/vim#7537)
38455a9213
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Solution for "!!sort" in closed fold is not optimal.
Solution: Use a different range instead of the subtle difference in handling
a range with an offset. (issue vim/vim#11487)
9954dc39ea
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Wrong argument for append() gives two error messages.
Solution: When getting an error for a number argument don't try using it as
a string. (closesvim/vim#11335)
801cd35e7e
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Assert_fails() setting emsg_silent changes normal execution.
Solution: Use a separate flag in_assert_fails.
28ee892ac4
Cherry-pick no_wait_return from patch 9.0.0846.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
When 'cmdheight' is changed while messages have scrolled, the position
of msg_grid is not moved up, so cmdline_row should not be set based on
the position of msg_grid.
Problem: "!!sort" in a closed fold sorts too many lines.
Solution: Round to end of fold after adding the line count. (closesvim/vim#11487)
f00112d558
N/A patches for version.c:
vim-patch:9.0.0855: comment not located above the code it refers to
Problem: Comment not located above the code it refers to.
Solution: Move the comment. (closesvim/vim#11527)
09a93e3e66
vim-patch:9.0.0859: compiler warning for unused variable
Problem: Compiler warning for unused variable.
Solution: Add #ifdef.
fd3084b6e2
Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor: move tabline code to statusline.c
Problem: Tabline code is closely related to statusline, but still left over in drawscreen.c and screen.c.
Solution: Move it to statusline.c.
* refactor: add statusline_defs.h
Update runtime files
76db9e0763
- `col()`'s example was changed to use `:echowin` so that the message can be
seen with `showmode`. Use "\n" to force a hit-enter instead as `:echowin`
isn't ported.
- Replace interpolated string usage in syntax/modula3.vim (not ported).
- Add a space after the `wincmd =` examples in `*CTRL-W_=*` so that the inlined
code is highlighted properly when followed by a full stop.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Previously man.lua would use the `env` field in the parameters of
`vim.loop.spawn` to override things like MANPAGER. This caused issues on
NixOS since `spawn` will _override_ the environment rather than _append_
to it (and NixOS relies on a heavily modified environment). Using the
`env` command to append to the environment solves this issue.
fix(vim.ui.input): return empty string when inputs nothing
The previous behavior of `vim.ui.input()` when typing <CR> with
no text input (with an intention of having the empty string as input)
was to execute `on_confirm(nil)`, conflicting with its documentation.
Inputting an empty string should now correctly execute `on_confirm('')`.
This should be clearly distinguished from cancelling or aborting the
input UI, in which case `on_confirm(nil)` is executed as before.
Problem: Handling 'statusline' errors is spread out.
Solution: Pass the option name to the lower levels so the option can be
reset there when an error is encountered. (Luuk van Baal,
closesvim/vim#11467)
7b224fdf4a
Problem: VHS tape files are not recognized.
Solution: Add a filetype pattern. (Carlos Alexandro Becker, closesvim/vim#11452)
1756f4b218
Co-authored-by: Carlos A Becker <caarlos0@users.noreply.github.com>
Adds a `name` key to the opts dict passed to Lua command callbacks
created using `nvim_create_user_command()`. This is useful for when
multiple commands use the same callback.
Note that this kind of behavior is not as strange as one might think,
even some internal Neovim commands reuse the same internal C function,
differing their behavior by checking the command name. `substitute`,
`smagic` and `snomagic` are examples of that.
This will also be useful for generalized Lua command preview functions
that can preview a wide range of commands, in which case knowing the
command name is necessary for the preview function to actually be able
to execute the command that it's supposed to preview.
Problem: "au!" and "au! event" cannot be followed by another command as
documented.
Solution: When a bar is found set nextcmd.
b8e642f7ac
Cherry-pick do_autocmd() "eap" argument from patch 8.2.3268.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Check for features implemented with "if".
Solution: Use the Check commands. (Ken Takata, closesvim/vim#7383)
aeb313f355
Cherry-pick test_compiler.vim changes from patch 8.1.2373.
Problem: Lambda for option that is a function may be garbage collected.
Solution: Set a reference in the funcref. (Yegappan Lakshmanan,
closesvim/vim#9330)
6ae8fae869
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Options that take a function insufficiently tested.
Solution: Add additional tests and enhance existing tests. (Yegappan
Lakshmanan, closesvim/vim#9298)
2172bff364
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Cannot assign a lambda to an option that takes a function.
Solution: Automatically convert the lambda to a string. (Yegappan
Lakshmanan, closesvim/vim#9286)
6409553b6e
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Cannot use a lambda for 'imactivatefunc'.
Solution: Add lambda support for 'imactivatefunc' and 'imstatusfunc'.
(Yegappan Lakshmanan, closesvim/vim#9275)
7645da568c
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
- `:write ++p foo/bar/baz.txt` should create parent directories `foo/bar/` if
they do not exist
- Note: `:foo ++…` is usually for options. No existing options have
a single-char abbreviation (presumably by design), so it's safe to
special-case `++p` here.
- Same for `writefile(…, 'foo/bar/baz.txt', 'p')`
- `BufWriteCmd` can see the ++p flag via `v:cmdarg`.
closes#19884
Error detected while processing function tutor#TutorCmd[38]..BufReadPost Autocommands for "*":
Error executing lua callback: ...llar/neovim/HEAD-cc5b736/share/nvim/runtime/filetype.lua:21: Error ex
ecuting lua: ...llar/neovim/HEAD-cc5b736/share/nvim/runtime/filetype.lua:22: Vim(let):E158: Invalid bu
ffer name: .
stack traceback:
[C]: in function 'nvim_cmd'
...llar/neovim/HEAD-cc5b736/share/nvim/runtime/filetype.lua:22: in function <...llar/neovim/HE
AD-cc5b736/share/nvim/runtime/filetype.lua:21>
[C]: in function 'nvim_buf_call'
...llar/neovim/HEAD-cc5b736/share/nvim/runtime/filetype.lua:21: in function <...llar/neovim/HE
AD-cc5b736/share/nvim/runtime/filetype.lua:10>
stack traceback:
[C]: in function 'nvim_buf_call'
...llar/neovim/HEAD-cc5b736/share/nvim/runtime/filetype.lua:21: in function <...llar/neovim/HE
AD-cc5b736/share/nvim/runtime/filetype.lua:10>
Closes https://github.com/neovim/neovim/issues/20920
Stale strategy is to never automatically stale anything. Only mark stale
issues or PRs if they get the `needs:response` label. In that case close
after 30 days if there hasn't been any activity.