aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript
Commit message (Collapse)AuthorAge
* fix(messages): add a trailing space to inputlist() etc. prompts (#32328)zeertzjq2025-02-05
| | | | Before #31525 the prompts had a trailing space. Also add a test for #7857.
* test(getchar_spec): fix flakiness (#32320)zeertzjq2025-02-04
| | | | | Problem: getchar_spec may fail when screen:expect_unchanged() doesn't wait long enough. Solution: Add poke_eventloop() before screen:expect_unchanged().
* vim-patch:9.1.1070: Cannot control cursor positioning of getchar() (#32303)zeertzjq2025-02-03
| | | | | | | | | | Problem: Cannot control cursor positioning of getchar(). Solution: Add "cursor" flag to {opts}, with possible values "hide", "keep" and "msg". related: vim/vim#10603 closes: vim/vim#16569 https://github.com/vim/vim/commit/edf0f7db28f87611368e158210e58ed30f673098
* vim-patch:9.1.1013: Vim9: Regression caused by patch v9.1.0646zeertzjq2025-01-16
| | | | | | | | | | | | | | | | Problem: Vim9: Regression caused by patch v9.1.0646 Solution: Translate the function name before invoking it in call() (Yegappan Lakshmanan) fixes: vim/vim#16430 closes: vim/vim#16445 https://github.com/vim/vim/commit/6289f9159102e0855bedc566636b5e7ca6ced72c N/A patch: vim-patch:8.2.4176: Vim9: cannot use imported function with call() Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* feat(ui)!: emit prompt "messages" as cmdline events #31525luukvbaal2025-01-02
| | | | | | | Problem: Prompts are emitted as messages events, where cmdline events are more appropriate. The user input is also emitted as message events in fast context, so cannot be displayed with vim.ui_attach(). Solution: Prompt for user input through cmdline prompts.
* fix(messages)!: vim.ui_attach message callbacks are unsafeLuuk van Baal2024-11-14
| | | | | | | | Problem: Lua callbacks for "msg_show" events with vim.ui_attach() are executed when it is not safe. Solution: Disallow non-fast API calls for "msg_show" event callbacks. Automatically detach callback after excessive errors. Make sure fast APIs do not modify Nvim state.
* fix(tests): needing two calls to setup a screen is cringebfredl2024-11-14
| | | | | | | | | | Before calling "attach" a screen object is just a dummy container for (row, col) values whose purpose is to be sent as part of the "attach" function call anyway. Just create the screen in an attached state directly. Keep the complete (row, col, options) config together. It is still completely valid to later detach and re-attach as needed, including to another session.
* refactor(tests): continue the global highlight definition workbfredl2024-11-08
|
* refactor(api)!: rename Dictionary => DictJustin M. Keyes2024-09-23
| | | | | | | | | | | | | | In the api_info() output: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val') ... {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1} The `ArrayOf(Integer, 2)` return type didn't break clients when we added it, which is evidence that clients don't use the `return_type` field, thus renaming Dictionary => Dict in api_info() is not (in practice) a breaking change.
* refactor(test): rename alter_slashes, invert its behaviorJustin M. Keyes2024-09-09
| | | | | | | - `alter_slashes` belongs in `testutil.lua`, not `testnvim.lua`. - `alter_slashes` is an unusual name. Rename it to `fix_slashes`. - invert its behavior, to emphasize that `/` slashes are the preferred, pervasive convention, not `\` slashes.
* fix(startup): server fails if $NVIM_APPNAME is relative dir #30310Justin M. Keyes2024-09-08
| | | | | | | | | | | | | | | | | | Problem: If $NVIM_APPNAME is a relative dir path, Nvim fails to start its primary/default server, and `v:servername` is empty. Root cause is d34c64e342dfba9248d1055e702d02620a1b31a8, but this wasn't noticed until 96128a5076b7 started reporting the error more loudly. Solution: - `server_address_new`: replace slashes "/" in the appname before using it as a servername. - `vim_mktempdir`: always prefer the system-wide top-level "nvim.user/" directory. That isn't intended to be specific to NVIM_APPNAME; rather, each *subdirectory* ("nvim.user/xxx") is owned by each Nvim instance. Nvim "apps" can be identified by the server socket(s) stored in those per-Nvim subdirs. fix #30256
* fix(startup): ignore broken $XDG_RUNTIME_DIR #30285Justin M. Keyes2024-09-08
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: $XDG_RUNTIME_DIR may be broken on WSL, which prevents starting (and even building) Nvim. #30282 Solution: - When startup fails, mention the servername in the error message. - If an autogenerated server address fails, log an error and continue with an empty `v:servername`. It's only fatal if a user provides a bad `--listen` or `$NVIM_LISTEN_ADDRESS` address. Before: $ nvim --headless --listen ./hello.sock nvim: Failed to --listen: "address already in use" $ NVIM_LISTEN_ADDRESS='./hello.sock' ./build/bin/nvim --headless nvim: Failed to --listen: "address already in use" After: $ nvim --headless --listen ./hello.sock nvim: Failed to --listen: address already in use: "./hello.sock" $ NVIM_LISTEN_ADDRESS='./hello.sock' ./build/bin/nvim --headless nvim: Failed $NVIM_LISTEN_ADDRESS: address already in use: "./hello.sock"
* feat(defaults): popupmenu "Open in browser", "Go to definition" #30261Justin M. Keyes2024-09-05
| | | | - Use the popup to expose more features such as LSP and gx. - Move the copy/paste items lower in the menu, they are lower priority.
* test: avoid noise in CI logs #30264Justin M. Keyes2024-09-05
| | | | | | | | | | | | | | | | | | Problem: Since 96128a5076b7 the test logs have noise from tests that *expect* failures: $NVIM_LOG_FILE: /tmp/cirrus-ci-build/build/.nvimlog (last 100 lines) ERR 2024-09-04T13:38:45.181 T949.28335.0/c terminfo_start:486: uv_pipe_open failed: no such device or address ERR 2024-09-04T13:38:45.181 T949.28335.0/c flush_buf:2527: uv_write failed: bad file descriptor ERR 2024-09-04T13:38:45.181 T949.28335.0/c flush_buf:2527: uv_write failed: bad file descriptor WRN 2024-09-04T13:43:43.294 ?.35904 server_start:173: Failed to start server: address already in use: /…/Xtest_tmpdir/…/T7159.35895.0 WRN 2024-09-04T13:43:43.314 ?.35907 server_start:173: Failed to start server: illegal operation on a directory: / ERR 2024-09-04T13:43:43.332 ?.35909 socket_watcher_init:60: Host lookup failed: https://example.com Solution: Rewrite the test to use `vim.system()`. Set NVIM_LOG_FILE in the child process to a "throwaway" logfile.
* test: tmpname(create:boolean) #30242Justin M. Keyes2024-09-03
| | | | | | | | | Problem: 137f98cf6428 added the `create` parameter to `tmpname()` but didn't fully implement it. Solution: - Update impl for the `os.tmpname()` codepath. - Inspect all usages of `tmpname()`, update various tests.
* feat(startup): validate --listen addressJustin M. Keyes2024-09-02
| | | | | | | | | | | | | Problem: `nvim --listen` does not error on EADDRINUSE. #30123 Solution: Now that `$NVIM_LISTEN_ADDRESS` is deprecated and input *only* (instead of the old, ambiguous situation where it was both an input *and* an output), we can be fail fast instead of trying to "recover". This reverts the "recovery" behavior of 704ba4151e7f67999510ee0ac19fdabb595d530c, but that was basically a workaround for the fragility of `$NVIM_LISTEN_ADDRESS`.
* refactor: add assertion for v_blob in tv_ptr() (#29554)zeertzjq2024-07-04
| | | Also add test for using printf() and id() with a Blob.
* refactor: use `vim._with` where possibledundargoc2024-06-28
| | | | | This mostly means replacing `nvim_buf_call` and `nvim_win_call` with `vim._with`.
* refactor(typval)!: remove distinction of binary and nonbinary stringsbfredl2024-06-27
| | | | | | | | | | | | | | | | | | | | | This is a breaking change which will make refactor of typval and shada code a lot easier. In particular, code that would use or check for v:msgpack_types.binary in the wild would be broken. This appears to be rarely used in existing plugins. Also some cases where v:msgpack_type.string would be used to represent a binary string of "string" type, we use a BLOB instead, which is vimscripts native type for binary blobs, and already was used for BIN formats when necessary. msgpackdump(msgpackparse(data)) no longer preserves the distinction of BIN and STR strings. This is very common behavior for language-specific msgpack bindings. Nvim uses msgpack as a tool to serialize its data. Nvim is not a tool to bit-perfectly manipulate arbitrary msgpack data out in the wild. The changed tests should indicate how behavior changes in various edge cases.
* feat(api): broadcast events to ALL channels #28487Justin M. Keyes2024-05-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: `vim.rpcnotify(0)` and `rpcnotify(0)` are documented as follows: If {channel} is 0, the event is broadcast to all channels. But that's not actually true. Channels must call `nvim_subscribe` to receive "broadcast" events, so it's actually "multicast". - Assuming there is a use-case for "broadcast", the current model adds an extra step for broadcasting: all channels need to "subscribe". - The presence of `nvim_subscribe` is a source of confusion for users, because its name implies something more generally useful than what it does. Presumably the use-case of `nvim_subscribe` is to avoid "noise" on RPC channels not expected a broadcast notification, and potentially an error if the channel client reports an unknown event. Solution: - Deprecate `nvim_subscribe`/`nvim_unsubscribe`. - If applications want to multicast, they can keep their own multicast list. Or they can use `nvim_list_chans()` and `nvim_get_chan_info()` to enumerate and filter the clients they want to target. - Always send "broadcast" events to ALL channels. Don't require channels to "subscribe" to receive broadcasts. This matches the documented behavior of `rpcnotify()`.
* test: improve test conventionsdundargoc2024-04-23
| | | | | | | | | Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
* test: make mapping tests more consistent (#28368)zeertzjq2024-04-16
| | | | | | - Test maparg() and maplist() in the same test. - Use matches() instead of string.match(). - Avoid overlong lines and strange spacing in exec_lua(). - Revert code change from last PR as the variable may be needed.
* refactor(test): inject after_each differentlyLewis Russell2024-04-10
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.
* test: fix vimscript/server_spec leaving behind a dir (#28204)zeertzjq2024-04-06
|
* fix: adjust error message for error in UI event callback (#28200)zeertzjq2024-04-06
| | | | | | Also close Nvim instance before removing log file, otherwise the Nvim instance will still write to the log file. Also adjust log level in libuv_process_spawn(). Ref #27660
* vim-patch:8.1.0815: dialog for file changed outside of Vim not tested (#28184)zeertzjq2024-04-05
| | | | | | | | | Problem: Dialog for file changed outside of Vim not tested. Solution: Add a test. Move FileChangedShell test. Add 'L' flag to feedkeys(). https://github.com/vim/vim/commit/5e66b42aae7c67a3ef67617d4bd43052ac2b73ce Co-authored-by: Bram Moolenaar <Bram@vim.org>
* test: use matches(...) instead of ok(string.find(...)) (#28111)zeertzjq2024-03-30
|
* refactor(tests): all screen tests should use highlightsbfredl2024-03-23
| | | | | | | | | | | | | | | | | | | | | | | This is the first installment of a multi-PR series significantly refactoring how highlights are being specified. The end goal is to have a base set of 20 ish most common highlights, and then specific files only need to add more groups to that as needed. As a complicating factor, we also want to migrate to the new default color scheme eventually. But by sharing a base set, that future PR will hopefully be a lot smaller since a lot of tests will be migrated just simply by updating the base set in place. As a first step, fix the anti-pattern than Screen defaults to ignoring highlights. Highlights are integral part of the screen state, not something "extra" which we only test "sometimes". For now, we still allow opt-out via the intentionally ugly screen._default_attr_ids = nil The end goal is to get rid of all of these eventually (which will be easier as part of the color scheme migration)
* refactor(tests): get channel id via nvim_get_chan_info #27441Justin M. Keyes2024-02-12
| | | Minor "best practices" nudge.
* vim-patch:9.1.0047: issues with temp curwin/buf while cmdwin is openSean Dewar2024-01-28
| | | | | | | | | | | | | | | | | Problem: Things that temporarily change/restore curwin/buf (e.g: win_execute, some autocmds) may break assumptions that curwin/buf is the cmdwin when "cmdwin_type != 0", causing issues. Solution: Expose the cmdwin's real win/buf and check that instead. Also try to ensure these variables are NULL if "cmdwin_type == 0", allowing them to be used directly in most cases without checking cmdwin_type. (Sean Dewar) Reset and save `cmdwin_old_curwin` in a similar fashion. Apply suitable changes for API functions and add Lua tests. https://github.com/vim/vim/commit/988f74311c26ea9917e84fbae608de226dba7e5f
* test: big cleanup followupLewis Russell2024-01-17
| | | | Followup to 07a7c0ec
* test: use integers for API Buffer/Window/Tabpage EXT typesLewis Russell2024-01-16
|
* test: rename (meths, funcs) -> (api, fn)Lewis Russell2024-01-12
|
* test: normalise nvim bridge functionsLewis Russell2024-01-12
| | | | | - remove helpers.cur*meths - remove helpers.nvim
* test: typing for helpers.methsLewis Russell2024-01-12
|
* test: use vim.mpack and vim.uv directlyLewis Russell2024-01-12
|
* test: remove helpers.sleep()Lewis Russell2024-01-12
|
* test: do not inject vim module into global helpersLewis Russell2024-01-12
|
* refactor: format test/*Justin M. Keyes2024-01-03
|
* build: enable lintlua for test/ dirJustin M. Keyes2024-01-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Not all Lua code is checked by stylua. Automating code-style is an important mechanism for reducing time spent on accidental (non-essential) complexity. Solution: - Enable stylua for entire `test/` directory. - Exclude these high-churn files until this issue is resolved: https://github.com/JohnnyMorganz/StyLua/issues/829 ``` test/functional/ui/decorations_spec.lua | 3560 ++++++++++++++++++++++++++++++++++++---------------- test/functional/ui/float_spec.lua | 5826 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------- test/functional/ui/multigrid_spec.lua | 1349 ++++++++++++++------ ``` - Make surgical changes to these files (or add `stylua: ignore` in some small scopes) to improve the result: ``` test/functional/vimscript/msgpack_functions_spec.lua | 1414 +++++++++++++++------ test/functional/api/buffer_spec.lua | 1389 +++++++++++---------- test/functional/api/vim_spec.lua | 2740 +++++++++++++++++++++++----------------- ``` - These "high churn" files are NOT excluded because the changes are largely an improvement: ``` test/functional/plugin/lsp_spec.lua | 2198 ++++++++++++++++++--------------- test/functional/plugin/shada_spec.lua | 4078 +++++++++++++++++++++++++++++++++++------------------------- test/functional/ui/cmdline_spec.lua | 1199 +++++++++++------- test/functional/ui/popupmenu_spec.lua | 1267 +++++++++++-------- test/functional/ui/messages_spec.lua | 1643 +++++++++++++++--------- ``` - TODO: how to check "all directories"? With `GLOB_DIRS *` and `/.deps/` (or `.deps/`) in `.styluaignore`, Lua code in `.deps/` is still checked...
* test(functional): remove faulty pending checkChristian Clason2023-12-30
| | | | | | | | | Problem: `functional/vimscript/api_functions_spec` skips a test if the runtime files are not generated, but this check was broken in a refactor. Solution: Since runtime files are now generated for all test targets, do not skip this test.
* fix(mappings): fix mapset() not replacing map with backslash (#26719)zeertzjq2023-12-23
|
* test: avoid repeated screen lines in expected stateszeertzjq2023-12-09
| | | | | | This is the command invoked repeatedly to make the changes: :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g
* feat(rpc): allow empty string key in msgpack => Vim conversionJustin M. Keyes2023-12-07
| | | | | | | | | | | | | | | | Problem: Since e057b38e7037 #20757 we support empty key in JSON encode/decode, but we don't allow it in RPC object => Vim dict conversion. But empty string is a valid key in Vim dicts and the msgpack spec. Empty string key was disallowed in 7c01d5ff9286 (2014) but that commit/PR doesn't explicitly discuss it, so presumably it was a "seems reasonable" decision (or Vimscript didn't allow empty keys until later). Solution: Remove the check in `object_to_vim()`. Note that `tv_dict_item_alloc_len` will invoke `memcpy(…, 0)` but that's allowed by the C spec: https://stackoverflow.com/a/3751937/152142
* fix(json): allow objects with empty keys #25564Emanuel2023-12-06
| | | | | | | | | | | | | | | | | | | | Problem: Empty string is a valid JSON key, but json_decode() treats an object with empty key as ":help msgpack-special-dict". #20757 :echo json_decode('{"": "1"}') {'_TYPE': [], '_VAL': [['', '1']]} Note: vim returns `{'': '1'}`. Solution: Allow empty string as an object key. Note that we still (currently) disallow empty keys in object_to_vim() (since 7c01d5ff9286d262097484c680e3a4eab49e2911): https://github.com/neovim/neovim/blob/f64e4b43e1191ff30d902730f752875aa55682ce/src/nvim/api/private/converter.c#L333-L334 Fix #20757 Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* revert: "memory: Free buffers after freeing variables" (#26356)zeertzjq2023-12-02
| | | | | | | | | This reverts commit fe30d8ccef17fff23676b8670dfec86444e2cb32. The original commit intends to prevent heap-use-after-free with EXITFREE caused by changedtick_di, which is no longer a problem. Freeing buffers after freeing variables will cause heap-use-after-free with EXITFREE when a partial is used as prompt callback.
* fix(context): don't leak memory on multiple invalid objects (#25979)zeertzjq2023-11-11
|
* fix(context): don't crash on invalid arg to nvim_get_context (#25977)zeertzjq2023-11-11
| | | | Note: The crash happens in the second test case when using uninitialized memory, and therefore doesn't happen with ASAN.
* vim-patch:8.2.4932: not easy to filter the output of maplist()zeertzjq2023-11-09
| | | | | | | | | Problem: Not easy to filter the output of maplist(). Solution: Add mode_bits to the dictionary. (Ernie Rael, closes vim/vim#10356) https://github.com/vim/vim/commit/d8f5f766219273a8579947cc80b92580b6988a4b Co-authored-by: Ernie Rael <errael@raelity.com>