Commit Graph

18964 Commits

Author SHA1 Message Date
Sean Dewar
89f7f7a991
vim-patch:8.2.1866: Vim9: appending to pushed blob gives wrong result
Problem:    Vim9: appending to pushed blob gives wrong result.
Solution:   Set ga_maxlen when copying a blob.
66fa5fd54f

Vim9script is N/A.
2021-09-16 20:20:43 +01:00
Sean Dewar
26d728fe7c
test(oldtest): re-order test_eval_stuff tests to match Vim 2021-09-16 20:09:56 +01:00
Sean Dewar
18b32fca67
fix(eval): add the vimscript-1 feature to has()
Include Test_string_concat_scriptversion1 to test that
has('vimscript-1') works (excluding the :scriptversion 1 bit).
2021-09-16 19:50:13 +01:00
Justin M. Keyes
9d5d72c388
fix(test runner): handle nil in no-colors output handler #15679
Problem:
13748512f6 #15610 The no-colors codepath of the nvim.lua test output
handler does not handle nil, leading to weird symptoms if e.g. a test
has a syntax error:

    test/busted/outputHandlers/nvim.lua:105: attempt to concatenate a nil value

Solution:
Coerce to string in no-colors handler.
2021-09-16 11:42:00 -07:00
Gregory Anders
d140d3bd33
fix(docs): ignore _*.lua files from auto doc generation #15678 2021-09-16 10:49:11 -07:00
Gregory Anders
0c86bf563c refactor: remove UTF to byte col conversion 2021-09-16 11:26:45 -06:00
zeertzjq
29bc648d2b
fix(man.vim): ensure buftype=nofile after :tag or :stag #15675
Problem:
`buftype=help` occasionally propagates from help to man buffer. As a result the
next time you open help it opens in the man window, replacing the manpage.

Test case:
    nvim -u NORC
    :Man man
    :set bt?            " should print `buftype=nofile`
    :help
    <C-W><C-W><C-W>c    " go back to :Man window and close it
    :help               " focus help window
    :Man man            " open window with manpage again
    :set bt?            " prints `buftype=help`

Solution:
- call s:set_options()
    - man#read_page() (called by autocmd BufReadCmd man://*) should already do
      this. But BufReadCmd doesn't fire for already-existing man:// buffers.

Fix #15650
2021-09-16 06:51:26 -07:00
Gregory Anders
4fa3865588 test: add test case for severity ranges 2021-09-15 19:09:21 -06:00
Sean Dewar
10283915d6
doc(eval): include latest relevant Blob changes
Also includes some small relevant nearby non-Blob changes and typo
fixes.

Changes are included from:
- v8.1.0815
- v8.1.0846
- v8.1.1084
- v8.1.2326
- v8.2.1969
- d89682477c
- d09091d495
- 53f7fccc94
2021-09-16 00:14:48 +01:00
Sean Dewar
6eb41e5c8d
test(oldtest): unskip existing tests that use Blobs 2021-09-16 00:14:48 +01:00
Sean Dewar
e53b71627f
feat(f_msgpackparse): support parsing from Blob
Note that it is not possible for msgpack_unpack_next() and
msgpack_unpacker_next() to return MSGPACK_UNPACK_EXTRA_BYTES, so it
should be fine to abort() on that.

Lua 5.1 doesn't support string hex escapes (\xXX) like VimL does (though
LuaJIT does), so convert them to decimal escapes (\DDD) in tests.
2021-09-16 00:14:47 +01:00
Sean Dewar
ddaa0cc9be
fix(test/dumplog): tostring(rv) before formatting as string
For example, implicitly converting a table to a string works in LuaJIT,
but needs to be done explicitly with tostring() in Lua 5.1.

This can cause issues when testing a non-JIT build if eq(), for example,
fails with a table argument. E.g: eq({}, {1}) will not print the details
of the assertion failure, but will instead print a less helpful "string
expected, got table" error.
2021-09-16 00:14:47 +01:00
Sean Dewar
5fdf741f77
feat(f_msgpackdump): support dumping to Blob 2021-09-16 00:14:47 +01:00
Sean Dewar
7e9ea08321
feat(f_chansend): support Blob data argument 2021-09-16 00:14:47 +01:00
Sean Dewar
e88961943b
fix(eval): partially port v8.2.3284
These were issues that I found while porting that I fixed upstream. :^)

Very little of the patch can be exactly ported as we're a bit behind on
dependant patches (we also can't use the exact :for emsg, as we don't
support iterating over Strings yet), so just translate the fixes as best
as we can for now.

Include latest relevant doc changes from:
- v8.1.0815
- v8.2.2658
2021-09-16 00:14:46 +01:00
Sean Dewar
3d6bb8b3fb
fix(f_remove): partially port v8.2.2779
Fixes remove() copying one extra byte after the end of a Blob's buffer.

Can't be fully ported as the change is from blob_remove(), which hasn't
been ported yet.
2021-09-16 00:14:46 +01:00
Sean Dewar
ecb54238e0
vim-patch:8.2.2712: memory leak when adding to a blob fails
Problem:    Memory leak when adding to a blob fails.
Solution:   Clear the second typval before returning.
f2dd9cb995
2021-09-16 00:14:46 +01:00
Sean Dewar
9e38c4a79f
vim-patch:8.2.1473: items in a list given to :const can still be modified
Problem:    Items in a list given to :const can still be modified.
Solution:   Work like ":lockvar! name" but don't lock referenced items.
            Make locking a blob work.
021bda5671
2021-09-16 00:13:41 +01:00
Sean Dewar
ffaf881b42
vim-patch:8.2.0829: filter() may give misleading error message
Problem:    filter() may give misleading error message.
Solution:   Also mention Blob as an allowed argument.
fcb0b61d15

Rename Test_map_fails() to Test_map_filter_fails() from v8.2.0610 and
include the modeline.
2021-09-15 22:57:55 +01:00
Sean Dewar
19232593ba
fix(f_insert): partially port v8.2.0634
Fixes a crash in f_insert() when inserting into a NULL blob.
Include blob-related test changes and some other simple changes.
2021-09-15 22:57:54 +01:00
Sean Dewar
9b5c9dbfa7
vim-patch:8.2.0521: crash when reading a blob fails
Problem:    Crash when reading a blob fails.
Solution:   Avoid keeping a pointer to a freed blob object. (Dominique Pelle,
            closes vim/vim#5890)  Adjust error messages.
15352dc6ec
2021-09-15 22:57:54 +01:00
Sean Dewar
ba34afb378
vim-patch:8.2.0404: writefile() error does not give a hint
Problem:    Writefile() error does not give a hint.
Solution:   Add remark about first argument.
18a2b87ca2
2021-09-15 22:57:54 +01:00
Sean Dewar
53f28f024c
vim-patch:8.2.0184: blob test fails
Problem:    Blob test fails.
Solution:   Check for different error when float feature is missing.
92be6e3f46

Nvim always has the float feature, but include the changes to the test
anyway.
2021-09-15 22:57:53 +01:00
Sean Dewar
ef76238548
vim-patch:8.2.0121: filter() and map() on blob don't work
Problem:    filter() and map() on blob don't work.
Solution:   Correct the code. (closes vim/vim#5483)
49c57ce500
2021-09-15 22:57:53 +01:00
Sean Dewar
726b255288
vim-patch:8.1.1671: copying a blob may result in it being locked
Problem:    Copying a blob may result in it being locked.
Solution:   Reset v_lock. (Ken Takata, closes vim/vim#4648)
b7b9efbccf
2021-09-15 22:57:53 +01:00
Sean Dewar
e7772c051f
vim-patch:8.1.1023: may use NULL pointer when indexing a blob
Problem:    May use NULL pointer when indexing a blob. (Coverity)
Solution:   Break out of loop after using index on blob
61be376337
2021-09-15 22:57:52 +01:00
Sean Dewar
bd9c787b4f
vim-patch:8.1.0802: negative index doesn't work for Blob
Problem:    Negative index doesn't work for Blob.
Solution:   Make it work, add a test. (closes vim/vim#3856)
a5be9b6248

Leave tv_blob_get()'s return type untouched.
2021-09-15 22:57:47 +01:00
Sean Dewar
23f5999d28
vim-patch:8.1.0798: changing a blob while iterating over it works strangely
Problem:    Changing a blob while iterating over it works strangely.
Solution:   Make a copy of the Blob before iterating.
dd29ea1805
2021-09-15 22:30:31 +01:00
Sean Dewar
e140eec441
vim-patch:8.1.0797: error E898 is used twice
Problem:    Error E898 is used twice.
Solution:   Rename the Blob error to E899. (closes vim/vim#3853)
bf821bccf1
2021-09-15 22:30:31 +01:00
Sean Dewar
c57132ec2a
vim-patch:8.1.0793: incorrect error messages for functions that take a Blob
Problem:    Incorrect error messages for functions that now take a Blob
            argument.
Solution:   Adjust the error messages. (Dominique Pelle, closes vim/vim#3846)
0d17f0d1c0
2021-09-15 22:30:31 +01:00
Sean Dewar
6a02ccc222
vim-patch:8.1.0765: string format of a Blob can't be parsed back
Problem:    String format of a Blob can't be parsed back.
Solution:   Use 0z format.
4131fd5509
2021-09-15 22:30:30 +01:00
Sean Dewar
0eadd7e5fd
vim-patch:8.1.0757: not enough documentation for Blobs
Problem:    Not enough documentation for Blobs.
Solution:   Add a section about Blobs.
d89682477c

Include doc changes for empty() from v7.4.1274.
Include some minor typo fixes.
2021-09-15 22:30:20 +01:00
Sean Dewar
2b98bdd75b
vim-patch:8.1.0756: copy() does not make a copy of a Blob
Problem:    copy() does not make a copy of a Blob.
Solution:   Make a copy.
3d28b58c51

Replace vim_memsave() with xmemdup().
2021-09-15 21:54:00 +01:00
Sean Dewar
c1b8731ece
vim-patch:8.1.0755: error message for get() on a Blob with invalid index
Problem:    Error message for get() on a Blob with invalid index.
Solution:   Return an empty Blob, like get() on a List does.
2ea773b468
2021-09-15 21:54:00 +01:00
Sean Dewar
d346ac536f
vim-patch:8.1.0742: not all Blob operations are tested
Problem:    Not all Blob operations are tested.
Solution:   Add more testing for Blob.
05500ece62

Test_readfile_binary is already ported.
2021-09-15 21:53:38 +01:00
Sean Dewar
7200454ee6
vim-patch:8.1.0738: using freed memory, for loop over blob leaks memory
Problem:    Using freed memory, for loop over blob leaks memory.
Solution:   Clear pointer after freeing memory.  Decrement reference count
            after for loop over blob.
ecc8bc482b
2021-09-15 21:19:31 +01:00
Sean Dewar
de9df825d5
feat(decode_string): decode binary string with NULs to Blob
Strings that previously decoded into a msgpack special for representing
BINs with NULs now convert to Blobs. It shouldn't be possible to decode
into this special anymore after this change?

Notably, Lua strings with NULs now convert to Blobs when passed to VimL.
2021-09-15 21:19:30 +01:00
Sean Dewar
ef729fb15b
feat(shada): restore Blob globals properly
As Strings and Blobs are encoded as msgpack BINs, the current ShaDa
implementation will restore global Blob variables as Strings (or msgpack
special dicts if they contain NULs).

Encode an additional element with Blob globals to differentiate them
from Strings so that we can restore them with the correct type.

Adjust variables_spec.lua's autotest() to also check for proper type.
2021-09-15 21:19:30 +01:00
Sean Dewar
af6f454f5c
feat(msgpack): convert Blobs to BIN strings 2021-09-15 21:19:30 +01:00
Sean Dewar
ab82369c8e
feat(json): convert Blobs to array of byte values
Similiar to how Vim does it, but to be consistent with how Nvim encodes
lists, add a space after every comma.
2021-09-15 21:19:29 +01:00
Sean Dewar
312c783d81
feat(api): convert Blobs to API strings
Note that these are not NUL-terminated; the API supports this.
2021-09-15 21:19:29 +01:00
Sean Dewar
10aa60e806
feat(nlua): convert Blobs to strings 2021-09-15 21:19:29 +01:00
Sean Dewar
bfeecd0b41
vim-patch:8.1.0736: code for Blob not sufficiently tested
Problem:    Code for Blob not sufficiently tested.
Solution:   Add more tests.  Fix uncovered crash.  Add test_null_blob().
c0f5a78c15

eval0 and ex_echo's emsg-specific changes have already been ported.
These tests uncover another crash that was fixed in v8.1.0738.
2021-09-15 21:19:29 +01:00
Sean Dewar
9095101743
vim-patch:8.1.0735: cannot handle binary data
Problem:    Cannot handle binary data.
Solution:   Add the Blob type. (Yasuhiro Matsumoto, closes vim/vim#3638)
6e5ea8d2a9

Nvim-specific Blob conversions are implemented in future commits.

Refactor write_blob() to use a FileDescriptor, as f_writefile() was
refactored to use one (does not apply to read_blob()).

Use var_check_lock() in f_add() for Blobs from v8.1.0897.

Add a modeline to test_blob.vim and fix some doc typos.

Include if_perl.txt's VIM::Blob() documentation. Interestingly, this
function already worked before this port, as it just returns a Blob
string literal, not an actual Blob object.

N/A patches for version.c:

vim-patch:8.1.0741: viminfo with Blob is not tested

Problem:    Viminfo with Blob is not tested.
Solution:   Extend the viminfo test.  Fix reading a blob.  Fixed storing a
            special variable value.
8c8b8bb56c

vim-patch:8.1.1022: may use NULL pointer when out of memory

Problem:    May use NULL pointer when out of memory. (Coverity)
Solution:   Check for blob_alloc() returning NULL.
e142a9467a
2021-09-15 21:19:22 +01:00
Gregory Anders
a5bbb932f9 refactor: move vim.lsp.diagnostic to vim.diagnostic
This generalizes diagnostic handling outside of just the scope of LSP.
LSP clients are now a specific case of a diagnostic producer, but the
diagnostic subsystem is decoupled from the LSP subsystem (or will be,
eventually).

More discussion at [1].

[1]: https://github.com/neovim/neovim/pull/15585
2021-09-15 14:09:47 -06:00
Michael Lingelbach
685cf39813
feat(lsp): improve logging (#15636)
* Simplify rpc encode/decode messages to rpc.send/rcp.receive
* Make missing handlers message throw a warning
* Clean up formatting style in log
* Move all non-RPC loop messages to trace instead of debug
* Add format func option to log to allow newlines in per log entry
2021-09-15 11:35:04 -07:00
Sean Dewar
afdc9e6150
fix(:source): copy curbuf lines to memory before sourcing #15111
It's possible for weirdness to happen if curbuf is modified while
sourcing from it via :source (with no arguments). For example:

- Deleting lines from or wiping curbuf can cause internal error E315 to
  be thrown from ml_get.
- Changing the curbuf to another buffer while sourcing can cause lines
  from the new curbuf to then be sourced instead.
2021-09-15 05:17:07 -07:00
Sean Dewar
6188926e00
fix(:source, nvim_exec): handle Vimscript line continuations #14809
Problem:
Anonymous :source (no args) and nvim_exec() don't support Vimscript line continuations.

Solution:
Factor out the concat logic into concat_continued_line() and a
CONCAT_CONTINUED_LINES macro for simple concatenations where lines are
fetched individually.

Closes #14807
2021-09-14 16:35:33 -07:00
Björn Linse
b86039b104 fix(ui): don't log from UI events during free_all_mem()
Example assertion failure:

   %0 in logmsg neovim/src/nvim/log.c:139:17
   %1 in ui_call_update_menu neovim/build/src/nvim/auto/ui_events_call.generated.h:8:3
   %2 in ex_menu neovim/src/nvim/menu.c:263:3
   %3 in do_one_cmd neovim/src/nvim/ex_docmd.c:1981:5
   %4 in do_cmdline neovim/src/nvim/ex_docmd.c:602:20
   %5 in do_cmdline_cmd neovim/src/nvim/ex_docmd.c:287:10
   %6 in free_all_mem neovim/src/nvim/memory.c:596:3
   %7 in os_exit neovim/src/nvim/main.c:574:3
   %8 in exit_event neovim/src/nvim/msgpack_rpc/channel.c:569:5
2021-09-14 21:01:15 +02:00
Justin M. Keyes
9edd17509f
Merge #15657 vim-patch:8.1.1195,8.2.{3417,3419} 2021-09-14 10:27:21 -07:00