Commit Graph

20 Commits

Author SHA1 Message Date
Ghjuvan Lacambre
ad9c2c069a
Fix <afile> getting prepended with a slash on WinClosed (#14515)
It is wrong to assume that you can't shorten a path if it's in `/`: you
can always shorten it by removing the forward slash.

Closes #14512
2021-06-26 10:18:36 -04:00
Justin M. Keyes
156c25e498 WinClosed: sort auevents.lua; improve tests
- test: reduce verbosity, condense redundancy, improve readability
- auevents.lua: keep events sorted by name. ref afd1d412fa
2020-01-18 21:32:14 -08:00
notomo
2b8e66c6ce autocmd: WinClosed exposes window id as <afile> 2020-01-18 17:06:03 -08:00
Marcos ALMEIDA
757aad92e8 autocmd: add WinClosed event
- only fire once, just before freeing mem
- trigger when on a different buffer
- avoid recursive calls in another tab
2020-01-18 17:06:03 -08:00
Daniel Hahler
3d1531aee5
API: include invalid buffer/window/tabpage in error message (#11712) 2020-01-14 09:21:10 +01:00
Justin M. Keyes
af946046b9 test: Rename meth_pcall to pcall_err
- Rename `meth_pcall`.
- Make `pcall_err` raise an error if the function does not fail.
- Add `vim.pesc()` to treat a string as literal where a Lua pattern is
  expected.
2019-09-06 17:19:07 -07:00
Justin M. Keyes
45c34bd84a
:doautocmd : Never show "No matching autocommands" #10689
The message is useless, it doesn't even mention the event name.

vim_dev discussion:
https://groups.google.com/forum/#!msg/vim_dev/RTbq58TMq9w/Xr4rSoUTCgAJ

ref: https://github.com/vim/vim/issues/4300
2019-08-05 03:33:45 +02:00
Björn Linse
8ed54bbec3 messages: use proper multiline error message for rpcrequest and API wrappers 2019-05-26 15:42:16 +02:00
Justin M. Keyes
a9d7ec4587 refactor: introduce XFREE_CLEAR()
Unfortunately we cannot indiscriminately replace xfree() with
XFREE_CLEAR(), because comparing pointers after freeing them is a common
pattern. Example in `tv_list_remove_items()`:

    xfree(li);
    if (li == item2) {
      break;
    }

Instead we can do it selectively/explicitly.

ref #1375
2019-05-25 10:01:17 +02:00
Björn Linse
74751117eb autocmd: fixes and tests for autocmd window issues
- redraw! in an invisible buffer rendered the screen unusable.
- storing the autocmd window handle and using it in API function could lead
  to crashes. Unregister the handle when the window is not active.
2019-05-13 20:32:04 +02:00
Justin M. Keyes
b1f25ea187 autocmd: do not show empty section after ++once handlers expire
Problem: If autocmd pattern only contained `++once` handlers, and
         all of them completed, then there would be an empty group
         displayed by `:autocmd Foo`.
Solution: Delete the pattern if all of its commands were deleted.
2019-03-14 01:30:11 +01:00
Justin M. Keyes
3259e45f92 autocmd: rename: "++nested", "++once"
Based on feedback from upstream:
https://github.com/vim/vim/pull/4100
2019-03-14 01:30:11 +01:00
Justin M. Keyes
9312e2d06a
autocmd: rename "once" => "-once" #9713
- Rename "nested" to "-nested", but continue to support "nested" for
  backwards-compatibility.
- Allow any order: "-once -nested" or "-nested -once".

ref https://github.com/neovim/neovim/pull/9706#issuecomment-471295747
2019-03-11 21:01:47 +01:00
Justin M. Keyes
c12cf5bde7 autocmd: introduce "once" feature
Adds a new feature to :autocmd which sets the handler to be executed at
most one times.

Before:

    augroup FooGroup
      autocmd!
      autocmd FileType foo call Foo() | autocmd! FooGroup * <buffer>
    augroup END

After:

    autocmd FileType foo once call Foo()
2019-03-10 04:58:30 +01:00
ZyX
f5be643205 functests: Fix linter errors 2017-04-09 03:31:13 +03:00
ZyX
b0731290e8 functests: Move test from legacy/009 to autocmd/autocmd 2017-04-08 21:50:14 +03:00
lonerover
2b56cf099a fix test failure 2017-01-09 13:06:24 +08:00
James McCoy
9d2985ecba vim-patch:7.4.1658
Problem:    A plugin does not know when VimEnter autocommands were already
            triggered.
Solution:   Add the v:vim_did_enter variable.

1473551a44
2016-11-14 14:16:40 -05:00
ZyX
ff470bb853 functests: Check logs in lua code
It is otherwise impossible to determine which test failed sanitizer/valgrind
check. test/functional/helpers.lua module return was changed so that tests which
do not provide after_each function to get new check will automatically fail.
2016-06-10 21:50:49 +03:00
Marco Hinz
a528d56ba0 Tests: add autocmd_spec.lua 2016-03-02 12:37:50 +01:00