All files under the os, api and msgpack_rpc directories have -Wconversion
automatically applied. CONV_SOURCES is also checked for missing files(when
renaming, for example)
Since all API functions now run immediately after a msgpack-rpc request is
parsed by libuv callbacks, a mechanism was added to override this behavior and
allow certain functions to run in Nvim main loop.
The mechanism is simple: Any API function tagged with the FUNC_ATTR_DEFERRED (a
"dummy" attribute only used by msgpack-gen.lua) will be called when Nvim main
loop receives a K_EVENT key.
To implement this mechanism it was necessary some restructuration on the
msgpack-rpc modules, especially in the msgpack-gen.lua script.
JobActivity autocommands run vimscript and must be executed on Nvim main loop.
Since the previous commit removed automatic calls to `event_push` on RStream/Job
callbacks, this adds it back, but in eval.c where job control is implemented.
A pattern that is becoming common across the project is to poll for events until
a certain condition is true, optionally passing a timeout. To address this
scenario, the event_poll_until macro was created and the job/channel/input
modules were refactored to use it on their blocking functions.
This is how asynchronous events are currently handled by Nvim:
- Libuv event loop is entered when Nvim blocks for user input(os_inchar is
called)
- Any event delivered by libuv that is not user input is queued for processing
- The `K_EVENT` special key code is returned by os_inchar
- `K_EVENT` is returned to a loop that is reading keys for the current Nvim
mode, which will be handled by calling event_process()
This approach has the advantage of integrating nicely with the current
codebase, eg: vimscript code can be executed asynchronously with little
surprises(Its the same as if the user typed a key).
The problem with using keys to represent any event is that it also interferes with
operators, and not every event needs or should do that. For example, consider
this scenario:
- A msgpack-rpc client calls vim_feedkeys("d")
- Nvim processes K_EVENT, pushing "d" to the input queue
- Nvim processes "d", entering operator-pending mode to wait for a motion
- The client calls vim_feedkeys("w"), expecting Nvim to delete a word
- Nvim processes K_EVENT, breaking out of operator-pending and pushing "w"
- Nvim processes "w", moving a word
This commit fixes the above problem by removing all automatic calls to
`event_push`(which is what generates K_EVENT input). Right now this also breaks
redrawing initiated by asynchronous events(and possibly other stuff too, Nvim is
a complex state machine and we can't simply run vimscript code anywhere).
In future commits the calls to `event_push` will be inserted only where it's
absolutely necessary to run code in "key reading loops", such as when executing
vimscript code or mutating editor data structures in ways that currently can
only be done by the user.
This approach is more flexible because we don't need to support a fixed set of
"event types", any module can push events to be handled in main loop by simply
passing a callback to the Event structure.
- Remove unused rpc_call_level field
- Add `returned` field to ChannelCallFrame. This is set when the call returns
and is the only condition checked by `channel_send_call`.
- Add job_exit callback for properly closing channels created from job(the
job_exit callback is only called after all read callbacks, so it's the only
safe place to free the channel).
Fixed a bug introduced in SHA:aa66f2487edde49b9a5ba10cd70d706d06a94e25,
due to a misapplied patch. buf_del_sign should redraw the window if the
sign deleted was the last one in the buffer.
Also moved the curwin verification to the correct function.
rbuffer_data was renamed to rbuffer_read_ptr, and it represents the next read
position in a RBuffer instance. Similarly, rbuffer_write_ptr was added to
represent the next write position.
Also, rbuffer_data was being used for writing(in alloc_cb), replace that by
rbuffer_write_ptr.
RBuffer instances represent the internal buffer used by RStreams.
This changes RStream constructor to receive RBuffer pointers and adds a set of
RBuffer methods that expose the lower level buffer manipulation to consumers of
the RStream API.
If we fail to bind to the server address, do not try and listen lest the
reported error always be "invalid argument".
Also, return whether or not we errored from server_init() in case we
want to respond differently in the future.
Problem: ml_get error for autocommand that moves the cursor of the
current window.
Solution: Check the cursor position after switching back to the current
buffer. (Christian Brabandt)
https://code.google.com/p/vim/source/detail?r=v7-4-436
Can't reliably get this information from cmake (#1267), so it's
misleading to show these messages at all. We can always revert this
commit if we find a way later.
- cmake: git_timestamp() returns last commit time formatted as
`YYYYMMddHHmm`.
- Always include commit hash in :version and --version output.
`nvim --version` sample output:
NVIM 0.0.0-alpha+201410070245 (compiled Oct 7 2014 05:30:45)
Commit: f747b2b1ff7bfe7eb00cc2be82d7af87c98f1111
- VIM_VERSION_LONG and VIM_VERSION_LONG_DATE do not affect plugins,
they are only cosmetic.
- Vim-related version identifiers will be preserved for plugin
compatibility (has("patchXXX") and v:version).
The os_system function uses a write callback to close the input stream when the
write completes, but this causes a memory error because the callback is invoked
right before the stream is freed by the caller.
This fixes the problem by removing the callback set by os_system. Instead, it
calls job_close_in immediately after writing(the stream will only close after
the write completes). The 'pending' parameter was also removed from the
'write_cb' as it should be hidden by the wstream module.
While the `wstream_set_write_cb` and `job_write_cb` are no longer used, they
will remain in the codebase for future use.
Problem: Using systemlist() may cause a crash and does not handle NUL
characters properly.
Solution: Increase the reference count, allocate memory by length. (Yasuhiro
Matsumoto)
https://code.google.com/p/vim/source/detail?r=v7-4-256
Problem: When passing input to system() there is no way to keep NUL and
NL characters separate.
Solution: Optionally use a list for the system() input. (ZyX)
https://code.google.com/p/vim/source/detail?r=v7-4-247
Implement write_list_to_string() as well since write_list() only works
on files.