Commit Graph

2636 Commits

Author SHA1 Message Date
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
Justin M. Keyes
5b04a4fa09 lua/shared: share trim() impl 2019-05-20 23:46:56 +02:00
Justin M. Keyes
7cc01c704c Merge #9709 'fileio: use os_copy to create backups'
ref #8288
2019-05-20 22:33:19 +02:00
Justin M. Keyes
e4c2d85c77 lua/shared: share deepcopy() with test/*
deepcopy() was duplicated in test/helpers.lua
2019-05-19 17:58:54 +02:00
Justin M. Keyes
9d7aaf7149 lua/shared: move table util funcs to vim.shared
Use `tbl_` prefix for all table-util functions. Specify in the function
docstring if it expects a list-like or map-like table.
2019-05-18 21:07:30 +02:00
Justin M. Keyes
fd04877eb0 test: remove use of require('test.helpers')
The test.functional.helpers and test.unit.helpers modules now include
all of the public functions from test.helpers, so there is no need to
separately require('test.helpers').
2019-05-18 15:48:13 +02:00
Justin M. Keyes
7669fc1e9b test: share implementation of testdir/load.vim
Also, don't compute load factor unless load_adjust() was called, it
slows down the test suite.

ref #9292
2019-05-18 15:48:13 +02:00
Justin M. Keyes
bba75eb184 lua/stdlib: Introduce vim.shared
This is where "pure functions" can live, which can be shared by Nvim and
test logic which may not have a running Nvim instance available.

If in the future we use Nvim itself as the Lua engine for tests, then
these functions could be moved directly onto the `vim` Lua module.

closes #6580
2019-05-18 15:48:13 +02:00
Justin M. Keyes
2b87485c22 test: Extend {unit,functional}.helpers with global helpers
Automatically include all "global helper" util functions in the
unit.helpers and functional.helpers and modules.  So tests don't need to
expicitly do:

    local global_helpers = require('test.helpers')
2019-05-18 14:51:01 +02:00
Björn Linse
94f78ccf89
Merge pull request #9883 from bfredl/termredraw
make terminal state redraw like any other state
2019-05-14 13:39:00 +02:00
Björn Linse
5020daa6e5 ui/terminal: make terminal state redraw like any other state
Previously, ordinary redraws were missing from terminal mode. Instead,
there was an async callback that invoked update_screen() on terminal
data regardless of mode (as if :redraw! was invoked by a timer).

This created some issues:

- async changes to an unrelated ordinary buffer were not always redrawn in
  terminal mode
- screen cursor position was not properly updated in terminal mode (partial
  fix, will be properly fixed in a follow up PR)
- ad-hoc logic was needed for interaction with special states such as
  inccommand or horizontal wildmenu.

Instead redraw terminal mode just like any other state. This disables forced
redraws in cmdline mode, which were inconisent which async changes to
normal buffers (which are not redrawn in cmdline mode).
2019-05-14 12:54:39 +02:00
Björn Linse
9e0982a1a2
Merge pull request #9985 from bfredl/shenanigans
Fix aucmd_win issues: crashes and redrawing errors.
2019-05-13 23:24:14 +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
60aaae1c86 API/nvim_set_keymap: remove mode-shortname aliases
Reduce the API surface-area a bit. No need to have aliases for a mode.
ref #9924
2019-05-12 13:27:07 +02:00
Justin M. Keyes
f35d233e07 API/nvim_set_keymap: minor cleanup
ref #9924
2019-05-12 13:04:48 +02:00
Yilin Yang
fbf2c414ad API: nvim_set_keymap, nvim_del_keymap #9924
closes #9136

- Treat empty {rhs} like <Nop>

- getchar.c: Pull "repl. MapArg termcodes" into func
  The "preprocessing code" surrounding the replace_termcodes calls needs
  to invoke replace_termcodes, and also check if RHS is equal to "<Nop>".
  To reduce code duplication, factor this out into a helper function.

  Also add an rhs_is_noop flag to MapArguments; buf_do_map_explicit
  expects an empty {rhs} string for "<Nop>", but also needs to distinguish
  that from something like ":map lhs<cr>" where no {rhs} was provided.

- getchar.c: Use allocated buffer for rhs in MapArgs
  Since the MAXMAPLEN limit does not apply to the RHS of a mapping (or
  else an RHS that calls a really long autoload function from a plugin
  would be incorrectly rejected as being too long), use an allocated
  buffer for RHS rather than a static buffer of length MAXMAPLEN + 1.

- Mappings LHS and RHS can contain literal space characters, newlines, etc.

- getchar.c: replace_termcodes in str_to_mapargs
  It makes sense to do this; str_to_mapargs is, intuitively, supposed to
  take a "raw" command string and parse it into a totally "do_map-ready"
  struct.

- api/vim.c: Update lhs, rhs len after replace_termcodes
  Fixes a bug in which replace_termcodes changes the length of lhs or rhs,
  but the later search through the mappings/abbreviations hashtables
  still uses the old length value. This would cause the search to fail
  erroneously and throw 'E31: No such mapping' errors or 'E24: No such
  abbreviation' errors.

- getchar: Create new map_arguments struct
  So that a string of map arguments can be parsed into a more useful, more
  portable data structure.

- getchar.c: Add buf_do_map function
  Exactly the same as the old do_map, but replace the hardcoded references
  to the global `buf_T* curbuf` with a function parameter so that we can
  invoke it from nvim_buf_set_keymap.

- Remove gettext calls in do_map error handling
2019-05-12 11:44:48 +02:00
Justin M. Keyes
24f9dd73d5 test/channels_spec: cleanup
- Remove stray print()
- Use uname() instead of system('uname')
2019-05-12 00:43:28 +02:00
Justin M. Keyes
3d1ed7c959 UI/ext_messages: learn more message kinds
ref #6201
2019-05-11 23:42:55 +02:00
Justin M. Keyes
b9ad12e6c2 UI/nvim_ui_attach(): add override option
Before now, Nvim always degrades UI capabilities to the lowest-common
denominator. For example, if any connected UI has `ext_messages=false`
then `ext_messages=true` requested by any other connected UI is ignored.

Now `nvim_ui_attach()` supports `override=true`, which flips the
behavior: if any UI requests an `ext_*` UI capability then the
capability is enabled (and the legacy behavior is disabled).

Legacy UIs will be broken while a `override=true` UI is connected, but
it's useful for debugging: you can type into the TUI and observe the UI
events from another connected (UI) client. And the legacy UI will
"recover" after the `override=true` UI disconnects.

Example using pynvim:

    >>> n.ui_attach(2048, 2048, rgb=True, override=True, ext_multigrid=True, ext_messages=True, ext_popupmenu=True)
    >>> while True: n.next_message();
2019-05-09 22:27:41 +02:00
hashinclude
400ee59247 API: fix cursor position when lines are added #9961
Restore code removed in #9674.
2019-05-07 09:17:37 +02:00
Justin M. Keyes
4b65a0059a test: cleanup
Avoid hyper-granularity. Don't need subdirectories for every little
thing.
2019-05-05 23:01:35 +02:00
Marco Hinz
1eda387951
tests: adjust to latest Vim patches 2019-05-05 14:05:25 +02:00
Marco Hinz
e6c21c4bc0
vim-patch:8.0.1782: no simple way to label quickfix entries
Problem:    No simple way to label quickfix entries.
Solution:   Add the "module" item, to be used instead of the file name for
            display purposes. (Martin Szamotulski)

d76ce85266
2019-05-05 13:46:19 +02:00
Justin M. Keyes
fd0fd752c8 terminal: swap priority of terminal, editor highlights
closes #9964
2019-05-02 09:56:22 +02:00
Carlo Abelli
49c51f839b ex_getln: fix statusline redraw logic #9967
fixes #9908
2019-05-02 11:38:21 +02:00
Justin M. Keyes
8aca932aa0
clipboard: setreg("*") with clipboard=unnamed #9954
Helped-by: Björn Linse <bjorn.linse@gmail.com>
fix #5646
2019-04-28 21:06:24 +02:00
Justin M. Keyes
769f44e918 win/defaults: Use "…/nvim-data/site" in 'runtimepath'
On Windows we store non-config data in "$XDG_DATA_HOME/nvim-data". But
the "…/site" items in 'runtimepath' did not correctly point to that
location, they used "…/nvim/site".

Fix the init logic to use  "…/nvim-data/site".

closes #9910
2019-04-28 00:27:07 +02:00
Justin M. Keyes
698c4f662d test: clear(): remove opts.headless parameter
Callers can instead specify `args_rm={'--headless'}`.

TODO: should `nvim_argv` have "--headless" by default? Need to inspect
      some uses of spawn(nvim_argv) ...
2019-04-27 16:31:26 +02:00
Justin M. Keyes
17291642bd test: clear(): args_rm parameter 2019-04-27 16:19:40 +02:00
Justin M. Keyes
f0a7e3fc9a test: 'shadafile' default
ref 773bdd41ec
2019-04-27 16:19:40 +02:00
Jan Edmund Lazo
9d77a07686 vim-patch:8.0.1510: cannot assert beep #9938
Problem:    Cannot test if a command causes a beep.
Solution:   Add assert_beeps().
b48e96f61c
2019-04-25 14:31:33 +02:00
Gabriel Cruz
8c6f5b7f92 Spurious quote mark in command line when typing <C-R> (#9934)
Remove <C-R> special char after reading following chars
2019-04-24 10:41:07 +02:00
glacambre
b3fd83a0ea Reset stop_insert_mode in terminal_enter rather than terminal_check
Problem: Using `:stopinsert` while in normal mode in a terminal buffer
prevents neovim from entering insert mode.

Solution: Move `stop_insert_mode = false` from terminal_check to
terminal_enter to be consistent with edit.c, as suggested by bfredl in
 #9889.

Closes https://github.com/neovim/neovim/issues/9889.
2019-04-20 10:41:46 +02:00
Björn Linse
0be8fb47a4
Merge pull request #9898 from bfredl/floatwidth
windows: float config changes
2019-04-14 13:35:11 +02:00
Björn Linse
c8acbe3b62 windows: float config changes
- Allow floating windows of width 1. #9846
- For a new floating window the size must be specified. Later on we
  might try to calculate a reasonable size by buffer contents
- Remember the configured size of a window, just like its position.
- Make get_config and set_config more consistent. Handle relative='' properly in set_config.
  get_config doesn't return keys that don't make sense for a non-floating window.
- Don't use width=0 for non-changed width, just omit the key.
2019-04-14 10:12:09 +02:00
Justin M. Keyes
dd9554a820 inccommand: Ignore :redraw during preview
closes #9777
2019-04-14 02:22:19 +02:00
Justin M. Keyes
82d48c0dab
Merge pull request #9896 from justinmk/api-async-error
API: emit nvim_error_event on failed async request
2019-04-13 19:53:09 +02:00
Justin M. Keyes
7e1591e06a API: emit nvim_error_event on failed async request
We already do this for _invalid_ async requests #9300.
Now we also do it for failed invocation of valid requests.
2019-04-13 17:07:58 +02:00
Marco Hinz
5f996e36d1
options: properly reset directories on 'autochdir' (#9894)
Fixes https://github.com/neovim/neovim/issues/9892
2019-04-13 12:50:36 +02:00
Gabriel Cruz
3b7a4f233b vim-patch:8.0.0714: cmdline redraw during timer #9835
vim-patch:8.0.0714: when a timer causes a command line redraw " goes missing
Problem:    When a timer causes a command line redraw the " that is displayed
            for CTRL-R goes missing.
Solution:   Remember an extra character to display.
a92522fbf3

vim-patch:8.0.0720: unfinished mapping not displayed when running timer
Problem:    Unfinished mapping not displayed when running timer.
Solution:   Also use the extra_char while waiting for a mapping and digraph.
            (closes vim/vim#1844)
6a77d2667e

close #9835
2019-04-12 03:20:05 +02:00
Marco Hinz
ae88e46563
float: always change to valid windows (#9878)
Using `:wincmd j` and friends doesn't make much sense to a floating window. For
convenience though, any direction will simply change to the previous window.

Make sure the previous window is valid, not the current window, and not another
floating window. Change to the first window (which is never a floating window)
otherwise.
2019-04-11 20:20:17 +02:00
Justin M. Keyes
ddd0eb6f51
startup: -es/-Es (silent/batch mode): skip swapfile #8540
To use Nvim as a scripting engine the side-effects of swapfiles and user
config should be avoided by default.
2019-04-10 03:27:25 +02:00
Björn Linse
5a81561e7a
Merge pull request #9866 from bfredl/setbufcursor
api/window: validate cursor in nvim_win_set_buf
2019-04-08 13:41:39 +02:00
Björn Linse
344c69b66b api/window: validate cursor in nvim_win_set_buf
validate_cursor() is called regularly, but only for the current window.
When changing the buffer for a non-current window, we need to invoke it
in the context of that window.
2019-04-08 12:39:08 +02:00
Justin M. Keyes
943bedfc86
event-loop: do not set CA_COMMAND_BUSY #9853
CA_COMMAND_BUSY in nv_event() was carried over from Vim nv_cursorhold()
(ref: e5165bae11). It prevents :startinsert from working during a RPC
call, so remove it.

Helped-by: glacambre <me@r4>
closes #7254
2019-04-08 02:33:00 +02:00
glacambre
d928b036dc :stopinsert should leave terminal-mode #9856
Problem:  Calling :stopinsert from RPC while in terminal-mode does not
          go back to normal-mode.
Solution: Implement a check() handler for state_enter(), adapted from
          insert_check().

Fix #7807
2019-04-08 01:13:43 +02:00
Justin M. Keyes
a7a56293aa
CI/AppVeyor: per-compiler deps cache #9852
The deps cache does not work for MSVC builds because the MINGW builds
ovewrite it.  Cache saves 10+ minutes on the build.
2019-04-07 03:54:22 +02:00
Marco Hinz
d9de4c0efb
vim-patch:8.1.1072: extending sign and foldcolumn below the text is confusing (#9816)
Problem:    Extending sign and foldcolumn below the text is confusing.
Solution:   Let the sign and foldcolumn stop at the last text line, just like
            the line number column.  Also stop the command line window leader.
            (Christian Brabandt)

8ee4c01b8c

Closes https://github.com/neovim/neovim/issues/9613
2019-04-03 10:48:47 +02:00
Justin M. Keyes
8eaa452073
Merge #9516 from erw7/improve-executable-on-windows
Improve executable() and exepath() on windows
2019-04-02 12:40:36 +02:00
Justin M. Keyes
c7039fd0d3 test: "$PATHEXT=::" 2019-04-02 01:28:11 +02:00