Commit Graph

1547 Commits

Author SHA1 Message Date
Justin M. Keyes
acfd2a2a29 input.c: Process only safe events before blocking.
Introduce multiqueue_process_priority() to process only events at or
above a certain priority.
2017-04-28 19:19:51 +02:00
Justin M. Keyes
3ea1007753 api: nvim_get_mode()
Asynchronous API functions are served immediately, which means pending
input could change the state of Nvim shortly after an async API function
result is returned.

nvim_get_mode() is different:
  - If RPCs are known to be blocked, it responds immediately (without
    flushing the input/event queue)
  - else it is handled just-in-time before waiting for input, after
    pending input was processed. This makes the result more reliable
    (but not perfect).

Internally this is handled as a special case, but _semantically_ nothing
has changed: API users never know when input flushes, so this internal
special-case doesn't violate that. As far as API users are concerned,
nvim_get_mode() is just another asynchronous API function.

In all cases nvim_get_mode() never blocks for more than the time it
takes to flush the input/event queue (~µs).

Note: This doesn't address #6166; nvim_get_mode() will provoke #6166 if
e.g. `d` is operator-pending.

Closes #6159
2017-04-28 19:14:34 +02:00
Justin M. Keyes
7044aa6e82 api/ext_tabline: curtab should be a Tabpage handle. 2017-04-28 15:59:20 +02:00
James McCoy
e20691ccb4
defaults_spec: Test changing :filetype/:syntax in -c, after defaults 2017-04-27 09:20:03 -04:00
Justin M. Keyes
6755262194 test: inccommand_spec: Avoid indeterminism. (#6592) 2017-04-26 14:51:21 +02:00
Justin M. Keyes
6944abad2f api/ext_tabline: List of Dicts. 2017-04-26 03:41:24 +02:00
Justin M. Keyes
c8e1af93de api: nvim_ui_attach(): Flatten ext_* options. 2017-04-26 03:41:24 +02:00
Justin M. Keyes
00843902d3 api/ui: externalize tabline
- Work with a bool[] array parallel to the UIWidget enum.
- Rename some functions.
- Documentation.
2017-04-26 03:41:24 +02:00
Dongdong Zhou
88023d5123 api/ui: externalize tabline 2017-04-26 02:15:31 +02:00
Justin M. Keyes
8f346a322b test/fs: sanity check for literal "~" directory (#6579)
If the CWD contains a directory with the literal name "~" then the tests
will have bogus failures.
2017-04-24 22:45:03 +02:00
Justin M. Keyes
086c354a0a api: Do not translate error messages.
Also re-word some error messages:
- "Key does not exist: %s"
- "Invalid channel: %<PRIu64>"
- "Request array size must be 4 (request) or 3 (notification)"
- "String cannot contain newlines"

References #6150
2017-04-24 00:11:27 +02:00
Sander Bosma
5c9860a0a2 api: Do not truncate errors <1 MB. #6237
Closes #5984
2017-04-23 23:44:29 +02:00
Justin M. Keyes
4524053874 test: api: Do not truncate errors <1 MB. 2017-04-23 23:24:16 +02:00
Justin M. Keyes
a9d37c928e Merge #6513 from ZyX-I/lazier-arg_errmsg-gettext 2017-04-23 01:02:39 +02:00
Justin M. Keyes
10f119ab87 Merge #6539 'More cursor shape modes' 2017-04-21 19:09:50 +02:00
sander2
f50e03f2e3 ex_cmds.c: Fix bug in ex_z (#6557)
vim-patch:8.0.0571
2017-04-21 15:45:51 +02:00
Björn Linse
48f0542ad6 tests: detect invalid helpers.sleep 2017-04-21 14:21:26 +02:00
Björn Linse
7ea5c78687 ui: use an array for mode styles 2017-04-21 12:32:38 +02:00
Björn Linse
2c5751b9b2 ui: add tests for new cursor shape modes 2017-04-21 12:32:38 +02:00
ZyX
d463c9e03a Merge branch 'master' into lazier-arg_errmsg-gettext 2017-04-21 00:33:12 +03:00
Justin M. Keyes
15af803cce Merge #6550 from ZyX-I/pvs-check-comment 2017-04-20 22:00:03 +02:00
Justin M. Keyes
17052946c7 'scrollback': Allow :setlocal -1 on normal buffers
Avoids a spurious :loadview error.
2017-04-20 13:13:39 +02:00
ZyX
c2f3e361c5 *: Add comment to all C files 2017-04-19 19:11:50 +03:00
Justin M. Keyes
45aa465fba test: Cursor after :hi clear|syntax reset
Also enable tests on Windows.
2017-04-17 21:15:51 +02:00
Matthew Malcomson
263849b2dd fold: foldMoveRange(): fix :move bug #6534
Closes #6540

In #6221 there was a mistake in calculating which folds need to be
re-ordered. When there are no folds after those that have been adjusted,
then `move_end` remains 0. This results in reverse_fold_order()
swapping folds that have been adjusted with uninitialised folds in the
remainder of the grow array.

Add a check in foldMoveRange() to account for this case.
2017-04-17 04:45:55 +02:00
Björn Linse
12fc1defd6 ops: fix i<c-r> with multi-byte text (#6524) 2017-04-15 11:19:40 +02:00
ZyX
b54e5c220f unittests: Add a test for TV_CSTRING
Not using enum{} because SIZE_MAX exceeds integer and I do not really like how
enum definition is described in C99:

1. Even though all values must fit into the chosen type (6.7.2.2, p 4) the type
   to choose is still implementation-defined.
2. 6.4.4.3 explicitly states that “an identifier declared as an enumeration
   constant has type `int`”. So it looks like “no matter what type was chosen
   for enumeration, constants will be integers”. Yet the following simple
   program:

        #include <stdint.h>
        #include <stdio.h>
        #include <stddef.h>

        enum { X=SIZE_MAX };

        int main(int argc, char **argv)
        {
          printf("x:%zu m:%zu t:%zu v:%zu",
                 sizeof(X), sizeof(SIZE_MAX), sizeof(size_t), (size_t)X);
        }

    yields one of the following using different compilers:

    - clang/gcc/pathcc: `x:8 m:8 t:8 v:18446744073709551615`
    - pcc/tcc: `x:4 m:8 t:8 v:1844674407370955161`

    If I remove the cast of X to size_t then pcc/tcc both yield `x:4 m:8 t:8
    v:4294967295`, other compilers’ output does not change.

    All compilers were called with `$compiler -std=c99 -xc -` (feeding program
    from echo), except for `tcc` which has missing `-std=c99`. `pcc` seems to
    ignore the argument though: it is perfectly fine with `-std=c1000`.
2017-04-14 23:58:47 +03:00
Justin M. Keyes
58d2ce9bdb test: check_cores(): Escape $TMPDIR path. (#6520)
Lua string:match() considers hyphen to be a special char, we want the
path to be a literal match. Also remove "./", etc.

References #6483
2017-04-14 20:34:54 +02:00
Justin M. Keyes
7c4e5dfd27 win: os_shell_is_cmdexe() + tests 2017-04-12 02:28:43 +02:00
Rui Abreu Ferreira
d31d177a0c win: default shellxescape, shellxquote to empty
Calling cmd.exe in Windows follows a very different pattern from Vim.
The primary difference is that Vim does a nested call to cmd.exe, e.g.
the following call in Vim

    system('echo a 2>&1')

spawns the following processes

    "C:\Program Files (x86)\Vim\vim80\vimrun" -s C:\Windows\system32\cmd.exe /c (echo a 2^>^&1
        ^>C:\Users\dummy\AppData\Local\Temp\VIoC169.tmp 2^>^&1)
    C:\Windows\system32\cmd.exe /c C:\Windows\system32\cmd.exe /c (echo a 2^>^&1
        ^>C:\Users\dummy\AppData\Local\Temp\VIo3C6C.tmp 2^>^&1)
    C:\Windows\system32\cmd.exe  /c (echo a 2>&1
        >C:\Users\dummy\AppData\Local\Temp\VIo3C6C.tmp 2>&1)

The escaping with ^ is needed because cmd.exe calls itself and needs to
preserve the special metacharacters for the last call. However in nvim
no nested call is made, system('') spawns a single cmd.exe process.
Setting shellxescape to "" disables escaping with ^.

The previous default for shellxquote=( wrapped any command in
parenthesis, in Vim this is more meaningful due to the use of tempfiles
to store the output and redirection (also see &shellquote). There is
a slight benefit in having the default be empty because some expressions
that run in console will not run within parens e.g. due to unbalanced
double quotes

    system('echo "a b')
2017-04-12 02:10:34 +02:00
Rui Abreu Ferreira
f3cc843755 win: libuv_process_spawn(): special-case cmd.exe
Disable CommandLineToArgvW-standard quoting for cmd.exe.

libuv assumes spawned processes follow the convention expected by
CommandLineToArgvW(). But cmd.exe is non-conformant, so for cmd.exe:
- With system([]), the caller has full control (and responsibility) to
  quote arguments correctly.
- With system(''), shell* options are used.

libuv quoting is disabled if argv[0] is:
- cmd.exe
- cmd
- $COMSPEC resolving to a path with filename cmd.exe

Closes #6329
References #6387
2017-04-12 02:10:34 +02:00
Rui Abreu Ferreira
799443c994 win/test: Enable more system() tests 2017-04-12 02:10:33 +02:00
Justin M. Keyes
d6e5f94ae9 win: defaults: 'shellredir', 'shellxquote', 'shellxescape' 2017-04-12 01:35:49 +02:00
Björn Linse
69775f603f ci: install Turkish locale and make locale tests more reliable 2017-04-11 10:24:19 +02:00
Justin M. Keyes
119f0ca854 test: helpers.execute() => helpers.feed_command() 2017-04-11 02:37:39 +02:00
Justin M. Keyes
dab3f86d09 win/test: Enable recover_spec.lua 2017-04-11 02:37:39 +02:00
Justin M. Keyes
2d29638744 test: :file {name} 2017-04-11 00:39:12 +02:00
Justin M. Keyes
6cbf290d56 test/rmdir(): fallback to Nvim delete()
Lua has too many pitfalls here:
- os.execute() requires shell-escaping
- os.execute() has breaking changes between Lua 5.1 and 5.2
- No native way in Lua to handle "readonly" etc. on Windows
2017-04-11 00:39:12 +02:00
Justin M. Keyes
0ce9618918 test/rmdir(): Remove readonly attr on Windows. 2017-04-10 22:59:30 +02:00
Justin M. Keyes
fec53f0bdf Merge #6479 from bfredl/tolower
remove vim_tolower/etc functions with broken locale-dependent behavior
2017-04-10 15:23:44 +02:00
Justin M. Keyes
dd7f41e5a0 Merge #6488 from ZyX-I/coverity-fixes 2017-04-10 14:04:19 +02:00
Björn Linse
a3a06d0248 test: add tests for gu/gU behavior in Turkish locale 2017-04-10 12:02:25 +02:00
ZyX
fa7ace446e coverity/56795: Fix NULL dereference in :syn keyword non-printable
Bug was introduced 3 years earlier, in 13848aa: NULL keyword_copy was 
incorrectly treated as an indicator of OOM.
2017-04-09 23:38:05 +03:00
ZyX
35584594f5 coverity/13689: Check file header with memcmp
Not that it is actually useful (would fail in any case), but should fix coverity 
report.
2017-04-09 22:30:48 +03:00
ZyX
8f75b67c07 coverity/13688: Check for NUL bytes in salfrom 2017-04-09 22:16:26 +03:00
ZyX
ecce981dba coverity/13687: Do not allow NUL byte in region names 2017-04-09 22:02:51 +03:00
ZyX
5b4f07ee86 spellfile: Use old error
This makes first test not actually show any change in behaviour.
2017-04-09 22:02:51 +03:00
ZyX
8d982ab522 coverity/13686: Do not allow NUL byte in precondition regex
Before this commit it emitted e_spell_trunc in the first case and
treated file as completely valid on the second. While first is fine
(both errors are actually valid, though old error is probably better),
second results in incorrect regex used.
2017-04-09 22:02:36 +03:00
ZyX
dbe67868b5 Merge branch 'master' into rename-execute 2017-04-09 19:14:20 +03:00
Justin M. Keyes
26bf6e6f6f test/check_cores(): Skip workspace-local temp dir. (#6483)
Avoids this error:
    ./test/helpers.lua:27: cannot open ./Xtest-tmpdir/nvimfqH9dL: No such file or directory
    stack traceback:
        ./test/helpers.lua:27: in function 'glob'
        ./test/helpers.lua:195: in function 'check_cores'
        ./test/functional/helpers.lua:628: in function <./test/functional/helpers.lua:626>
2017-04-09 15:49:31 +02:00