diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2023-07-23 19:50:20 +0100 |
---|---|---|
committer | Sean Dewar <seandewar@users.noreply.github.com> | 2023-07-26 20:44:46 +0100 |
commit | 6b4970f6e0ac36021b2a8bd0533f5078040d31f7 (patch) | |
tree | 32475f64281855f8a1cb6a62d3f232a1906cf9bd /src/nvim/api/vim.c | |
parent | ccf328172bac2b02f9bd19fa58e105958514a28a (diff) | |
download | rneovim-6b4970f6e0ac36021b2a8bd0533f5078040d31f7.tar.gz rneovim-6b4970f6e0ac36021b2a8bd0533f5078040d31f7.tar.bz2 rneovim-6b4970f6e0ac36021b2a8bd0533f5078040d31f7.zip |
feat(api): allow open_win/win_set_buf in the cmdwin in some cases
Problem: As discussed on Matrix, there was some interest in having
`nvim_open_win` again be able to open floats in the cmdwin (e.g: displaying a
hover doc related to what's in the cmdwin). After #23228, this was disallowed.
Solution: Allow `nvim_open_win` in the cmdwin as long as `!enter` and
`buffer != curbuf` (the former can cause all sorts of issues, and the latter
can crash Nvim after closing cmdwin). Also allow `nvim_win_set_buf` in a similar
fashion.
Note that we're not *entirely* sure if this is 100% safe (cmdwin is a
global-state-using-main-loop-calling beast), but this seems to work OK..?
Also:
- Check the buffer argument of `nvim_open_win` earlier, and abort if it's
invalid (it used to still open a window in this case).
- Untranslate `e_cmdwin` errors in the API (other errors in the API are not
translated: although not detailed in the API contract yet, errors are
supposed to be stable).
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 8738b3e38e..b4a6fa718b 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -967,7 +967,7 @@ Integer nvim_open_term(Buffer buffer, DictionaryOf(LuaRef) opts, Error *err) } if (cmdwin_type != 0 && buf == curbuf) { - api_set_error(err, kErrorTypeException, "%s", _(e_cmdwin)); + api_set_error(err, kErrorTypeException, "%s", e_cmdwin); return 0; } |