Commit Graph

1879 Commits

Author SHA1 Message Date
Thiago de Arruda
4fd9ee4a6b input/job: process ctrl+c and do conversion in the read callback
- Extract `process_interrupts` out of `convert_input`
- Instead of waiting for os_breakcheck/os_inchar calls, call `convert_input`
  and `process_interrupts` directly from the read callback in input.c.
- Remove the `settmode` calls from `job_wait`. Now that interrupts are
  processed in the event loop, there's no need to set the terminal to cooked
  which introduces other problems(ref 7.4.427)
2014-10-29 23:08:43 -03:00
Justin M. Keyes
49d5ed5591 fix #1027: :wundo segfault in new, non-empty buffer 2014-10-26 20:03:02 +00:00
Justin M. Keyes
3fc542b45b Merge pull request #1347 from splinterofchaos/433
vim-patch:7.4.433
2014-10-29 12:09:02 -04:00
Justin M. Keyes
72c54db443 Merge #1342 "signs bugfix" 2014-10-28 23:14:15 -04:00
Kartik K. Agaram
250298884b fix 'sign unplace id'
Since the introduction of the FOR_ALL_BUFFERS macro, 'sign unplace id'
without a buffer was only removing the sign from the first buffer rather
than all buffers, as described in the documentation.

  :help sign-unplace

--

modeline discussion: https://github.com/akkartik/neovim/commit/7863c247db#commitcomment-8342590
2014-10-28 23:12:41 -04:00
Thiago de Arruda
94f59fc9be api: Implement vim_command_output function
This function can be used by API clients to execute a command and capture the
output.
2014-10-28 23:12:41 -04:00
Thiago de Arruda
c28adf15e6 Merge PR #1350 'valgrind/jobs: Fix invalid reads.' 2014-10-28 14:11:32 -03:00
Scott Prager
7203796c54 test/job: Implement some basic jobs tests. 2014-10-28 14:09:28 -03:00
Scott Prager
860b6f6f05 test/shell: Add failure tests for system(). 2014-10-28 14:09:28 -03:00
Scott Prager
dd4263a0c8 job_start: Do not close in/out/err on error.
The streams job_close_*() reference have not been initialized by the
time we call uv_spawn() and libuv closes these pipes for us when spawn()
fails.
2014-10-28 14:09:28 -03:00
Scott Prager
d10e83fec2 job/valgrind: Fix invalid reads/missing free.
The JobEvent structure may refer to a job after it has been freed. Apply
@tarruda's patch to extract the job data before pushing the event.

Also, fix the type, "data" -> "job", in on_job_exit() and free the job
name in the last job event.
2014-10-28 14:09:28 -03:00
Thiago de Arruda
7797991ba5 Merge PR #1354 'Fixes to channel.c, input.c and helpers.lua' 2014-10-28 11:04:55 -03:00
Thiago de Arruda
c95bc3349b input: Fix conversion error in convert_input()
The `rbuffer_consumed` was being passed a consumed count from another buffer,
causing integer overflow in `rbuffer_relocate`.

Fixes #1343
2014-10-28 10:21:05 -03:00
Thiago de Arruda
53ce5493fa test: Small fixes and improvements to functional helpers.lua
- Move the cleanup function definition into `restart()` so restart can be
  selectively used as a hook
- Improve error handling: Before this, errors while running the event loop would
  cause busted to get stuck. Now the error is properly raised by stopping the
  event loop first.
2014-10-28 09:11:40 -03:00
Thiago de Arruda
4d70fe89bf msgpack-rpc: Terminate server->client calls when the channel closes 2014-10-28 08:54:44 -03:00
Thiago de Arruda
3cacdae044 channel: fix REQ definition for msgpack-rpc logging 2014-10-28 08:54:24 -03:00
Scott Prager
ba527b6f34 version: Mark patch 430 NA.
Not relevant because we always compile with +conceal.
2014-10-25 14:53:32 -04:00
Scott Prager
d14c124847 vim-patch:7.4.433
Problem:    Test 75 fails on MS-Windows.
Solution:   Use ":normal" instead of feedkeys(). (Michael Soyka)

https://code.google.com/p/vim/source/detail?r=v7-4-433
2014-10-25 14:52:29 -04:00
Thiago de Arruda
65942d3a8d Merge PR #1331 'Fixes to job and channel modules' 2014-10-23 22:19:18 -03:00
Thiago de Arruda
d696fa51f8 test: verify that msgpacks-rpc exceptions are working 2014-10-23 21:46:09 -03:00
Thiago de Arruda
64844b7312 msgpack-rpc: Improve logging of msgpack-rpc messages
- Expose more logging control from the log.c module(get log stream and omit
  newlines)
- Remove logging from the generated functions in msgpack-gen.lua
- Refactor channel.c/helpers.c to log every msgpack-rpc payload using
  msgpack_object_print(a helper function from msgpack.h)
- Remove the api_stringify function, it was only useful for logging msgpack-rpc
  which is now handled by msgpack_object_print.
2014-10-23 21:46:03 -03:00
Thiago de Arruda
f05fead12e job: Only decrease refcount after settmode in job_wait
This is required to prevent the scenario explained by @akkartik in #1324
2014-10-23 21:19:08 -03:00
Thiago de Arruda
6f5f3faa84 travis: Setup xvfb for running xclip tests 2014-10-23 21:19:08 -03:00
Thiago de Arruda
d561ba223d job: Refactor to ensure that all callbacks will be invoked
It's possible that a child process won't close it's standard streams, even after
it exits. This can be evidenced with the "xclip" program:

    :call system('xclip -i -selection clipboard', 'DATA')

Before this commit, the above command wouldn't return, even though the xclip
program had exited. That is because `xclip` wasn't closing it's stdout/stderr
streams, which would block pending_refs from ever reaching 0.

Now the job.c module was refactored to ensure all streams are closed when the
uv_process_t handle is closed.
2014-10-23 21:19:08 -03:00
Thiago de Arruda
9abcd9a4a0 msgpack-rpc: Fix error handling and leak in call_request_handler
Free the arguments array after sending the response and also avoid
double-sending responses in cases of errors.
2014-10-23 21:19:08 -03:00
Thiago de Arruda
d4f78127fb msgpack-rpc: Ensure stdio channels are properly closed
When stdio was closed, parse_msgpack was called with eof == true, with caused a
free_channel call. To ensure the correct behavior for all types of channels, the
close_channel must be called before free_channel.
2014-10-23 21:19:08 -03:00
Thiago de Arruda
b4ec764e8e runtime: Fix rpcstop call in python_setup.vim 2014-10-23 21:19:08 -03:00
Justin M. Keyes
d1e063a8af Merge pull request #1332 from splinterofchaos/listbr
vim-patch:7.4.422
2014-10-23 15:20:01 -04:00
Scott Prager
87cf661af6 vim-patch:7.4.422
Problem:    When using conceal with linebreak some text is not displayed
            correctly. (Grüner Gimpel)
Solution:   Check for conceal mode when using linebreak. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=v7-4-422
2014-10-23 14:37:55 -04:00
Justin M. Keyes
b8401550a7 Merge pull request #1330 from splinterofchaos/na-patches
N/A patches
2014-10-23 14:22:01 -04:00
Scott Prager
089f977d18 version: update patches to 488 2014-10-23 13:18:02 -04:00
Scott Prager
95cdf32f24 version: More NA patches. 2014-10-23 13:18:02 -04:00
Scott Prager
46c610c9fe vim-patch:7.4.406
Problem:    Test 72 and 100 fail on MS-Windows.
Solution:   Set fileformat to unix in the tests. (Taro Muraoka)

https://code.google.com/p/vim/source/detail?r=v7-4-406
2014-10-23 13:18:02 -04:00
Nate Sullivan
d11fd1950f legacy tests: migrate test35. #1318
Migrate vim's integration test 35 (increment/decrement commands) to
lua/busted.
2014-10-22 15:28:26 -04:00
Thiago de Arruda
2f31c3d6ce Merge PR #1326 'Add verification of log macros' 2014-10-22 11:40:38 -03:00
Thiago de Arruda
b31a74ad11 debug: Improve debugging of msgpack-rpc requests
- Add the api_stringify function to display API objects
- Use api_stringify to display request arguments and return values in DLOG
  statements.
2014-10-22 11:26:43 -03:00
Thiago de Arruda
4233446344 debug: Fix broken DLOG macro calls 2014-10-22 11:26:43 -03:00
Thiago de Arruda
97f0c1eda1 travis: Force verification of DLOG macros
We use INFO as the default log level, which leaves code inside DLOG macros
unverified(currently it has compilation errors).

Decrease the log level on travis builds for automatic verification in PRs.
2014-10-22 11:26:36 -03:00
Thiago de Arruda
cdfdfae322 input: Fix ctrl+c handling in convert_input 2014-10-22 09:58:17 -03:00
Thiago de Arruda
5cd9b64742 Merge PR #1316 'Refactor event deferral' 2014-10-22 07:30:32 -03:00
Thiago de Arruda
f7fab4af86 test: verify that v:shell_error is set by system()/systemlist() 2014-10-22 07:15:55 -03:00
Thiago de Arruda
b49460f930 input: Don't remove Ctrl+C from the input_buffer 2014-10-21 21:20:31 -03:00
Thiago de Arruda
b6c9883169 event: Remove direct calls to uv_run from job.c/shell.c 2014-10-21 12:27:25 -03:00
Thiago de Arruda
276ac99350 travis: Remove install_functional_test_deps function
It is no longer needed after the lua client was added as dependency
(@69561ea922ae6789703c06cbc245929d7c625db9)
2014-10-21 11:07:13 -03:00
Thiago de Arruda
79b7263f79 compilation: Add -Wconversion to more files and validate CONV_SOURCES
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)
2014-10-21 11:05:49 -03:00
Thiago de Arruda
cf9571b7b1 api: Add FUNC_ATTR_DEFERRED attribute to a number of functions
Any function that can directly mutate the screen or execute vimscript had the
attribute applied.
2014-10-21 11:05:49 -03:00
Thiago de Arruda
72e3e57bf1 msgpack-rpc: Allow selective deferral API calls
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.
2014-10-21 11:05:49 -03:00
Thiago de Arruda
72f028abcb eval: Defer execution of JobActivity autocommands
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.
2014-10-21 11:05:49 -03:00
Thiago de Arruda
b527ac752f event: Extract event_poll loops to event_poll_until macro
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.
2014-10-21 11:05:49 -03:00
Thiago de Arruda
264e0d872c event: Remove automatic event deferall
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.
2014-10-21 11:05:49 -03:00