James McCoy
9ff0cc7085
Merge pull request #6808 from nelstrom/normal-mode-terminal
...
Make :terminal remain in normal mode when created
2017-08-21 19:46:43 -04:00
Lech Lorens
d2595ba1c4
vim-patch:8.0.0092
...
Problem: C indenting does not support nested namespaces that C++ 17 has.
Solution: Add check that passes double colon inside a name. (Pauli, closes
vim/vim#1214 )
ca8b8d6956
2017-08-21 23:00:51 +02:00
Drew Neil
73286a81cf
Repair tui_spec functional tests
2017-08-21 20:44:03 +01:00
Drew Neil
ac52947838
Repair job_spec functional tests
2017-08-21 20:44:03 +01:00
Drew Neil
642e14d9e7
Repair ex_terminal_spec functional tests
2017-08-21 20:44:03 +01:00
Drew Neil
5a214a9ed0
Update documentation
2017-08-21 20:44:03 +01:00
Drew Neil
7d183e89f7
Use Normal mode as default when opening a new terminal
2017-08-21 20:44:03 +01:00
Justin M. Keyes
0f442c328e
channel.c:call_set_error(): fix memory leak
2017-08-21 01:04:28 +02:00
Justin M. Keyes
af993da435
rpc: close channel if stream was closed
...
f_jobstop()/f_rpcstop() .. process_stop() .. process_close_in(proc)
closes the write-stream of a RPC channel. But there might be
a pending RPC notification on the queue, which may get processed just
before the channel is closed.
To handle that case, check the Stream.closed in
channel.c:receive_msgpack().
Before this change, the above scenario could trigger
this assert(!stream->closed) in wstream_write():
0x00007f96e1cd3428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
0x00007f96e1cd502a in __GI_abort () at abort.c:89
0x00007f96e1ccbbd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x768f9b "!stream->closed",
file=file@entry=0x768f70 "../src/nvim/event/wstream.c", line=line@entry=77,
function=function@entry=0x768fb0 <__PRETTY_FUNCTION__.13735> "wstream_write") at assert.c:92
0x00007f96e1ccbc82 in __GI___assert_fail (assertion=0x768f9b "!stream->closed", file=0x768f70 "../src/nvim/event/wstream.c", line=77,
function=0x768fb0 <__PRETTY_FUNCTION__.13735> "wstream_write") at assert.c:101
0x00000000004d2c1f in wstream_write (stream=0x7f96e0a35078, buffer=0x7f96e09f9b40) at ../src/nvim/event/wstream.c:77
0x00000000005857b2 in channel_write (channel=0x7f96e0ae5800, buffer=0x7f96e09f9b40) at ../src/nvim/msgpack_rpc/channel.c:551
0x000000000058567d in on_request_event (argv=0x7ffed792efa0) at ../src/nvim/msgpack_rpc/channel.c:523
0x00000000005854c8 in handle_request (channel=0x7f96e0ae5800, request=0x7ffed792f1b8) at ../src/nvim/msgpack_rpc/channel.c:503
0x00000000005850cb in parse_msgpack (channel=0x7f96e0ae5800) at ../src/nvim/msgpack_rpc/channel.c:423
0x0000000000584f90 in receive_msgpack (stream=0x7f96e0a35218, rbuf=0x7f96e0d1d4c0, c=22, data=0x7f96e0ae5800, eof=false)
at ../src/nvim/msgpack_rpc/channel.c:389
0x00000000004d0b20 in read_event (argv=0x7ffed792f4a8) at ../src/nvim/event/rstream.c:190
0x00000000004ce462 in multiqueue_process_events (this=0x7f96e18172d0) at ../src/nvim/event/multiqueue.c:150
0x000000000059b630 in nv_event (cap=0x7ffed792f620) at ../src/nvim/normal.c:7908
0x000000000058be69 in normal_execute (state=0x7ffed792f580, key=-25341) at ../src/nvim/normal.c:1137
0x0000000000652463 in state_enter (s=0x7ffed792f580) at ../src/nvim/state.c:61
0x000000000058a1fe in normal_enter (cmdwin=false, noexmode=false) at ../src/nvim/normal.c:467
0x00000000005500c2 in main (argc=2, argv=0x7ffed792f8d8) at ../src/nvim/main.c:554
Alternative approach suggested by bfredl is to use close_cb of the
process. My unsuccessful attempt is below. (It seems close_cb is queued
too late, which is the similar problem addressed by this commit):
commit 75fc12c6ab15711bdb7b18c6d42ec9d157f5145e
Author: Justin M. Keyes <justinkz@gmail.com>
Date: Fri Aug 18 01:30:41 2017 +0200
rpc: use Stream's close_cb instead of explicit check in receive_msgpack()
diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c
index 8371d3cd482e..e52da23cdc40 100644
--- a/src/nvim/event/process.c
+++ b/src/nvim/event/process.c
@@ -416,6 +416,10 @@ static void on_process_exit(Process *proc)
static void on_process_stream_close(Stream *stream, void *data)
{
Process *proc = data;
+ ILOG("on_process_stream_close");
+ if (proc->stream_close_cb != NULL) {
+ proc->stream_close_cb(stream, proc->stream_close_data);
+ }
decref(proc);
}
diff --git a/src/nvim/event/process.h b/src/nvim/event/process.h
index 5c00e8e7ecd5..34a8d54f6f8c 100644
--- a/src/nvim/event/process.h
+++ b/src/nvim/event/process.h
@@ -26,6 +26,11 @@ struct process {
Stream *in, *out, *err;
process_exit_cb cb;
internal_process_cb internal_exit_cb, internal_close_cb;
+
+ // Called when any of the process streams (in/out/err) closes.
+ stream_close_cb stream_close_cb;
+ void *stream_close_data;
+
bool closed, detach;
MultiQueue *events;
};
@@ -50,6 +55,8 @@ static inline Process process_init(Loop *loop, ProcessType type, void *data)
.closed = false,
.internal_close_cb = NULL,
.internal_exit_cb = NULL,
+ .stream_close_cb = NULL,
+ .stream_close_data = NULL,
.detach = false
};
}
diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c
index 7c865bfe1e8c..c8720d1e45d9 100644
--- a/src/nvim/event/stream.c
+++ b/src/nvim/event/stream.c
@@ -95,7 +95,11 @@ void stream_close(Stream *stream, stream_close_cb on_stream_close, void *data)
void stream_close_handle(Stream *stream)
FUNC_ATTR_NONNULL_ALL
{
+ ILOG("stream=%d", stream);
+ // LOG_CALLSTACK();
if (stream->uvstream) {
+ // problem: this schedules on the queue, but channel.c:receive_msgpack may
+ // be processed before close_cb is called by libuv.
uv_close((uv_handle_t *)stream->uvstream, close_cb);
} else {
uv_close((uv_handle_t *)&stream->uv.idle, close_cb);
@@ -105,6 +109,7 @@ void stream_close_handle(Stream *stream)
static void close_cb(uv_handle_t *handle)
{
Stream *stream = handle->data;
+ ILOG(">>>>>>>>>>>>>>>>>>>>>>> stream=%p stream->internal_close_cb=%p", stream, stream->internal_close_cb);
if (stream->buffer) {
rbuffer_free(stream->buffer);
}
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index 782eabe04e4a..dc2b794e366a 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -128,6 +128,8 @@ uint64_t channel_from_process(Process *proc, uint64_t id, char *source)
source);
incref(channel); // process channels are only closed by the exit_cb
channel->data.proc = proc;
+ channel->data.proc->stream_close_cb = close_cb2;
+ channel->data.proc->stream_close_data = channel;
wstream_init(proc->in, 0);
rstream_init(proc->out, 0);
@@ -387,17 +389,6 @@ static void receive_msgpack(Stream *stream, RBuffer *rbuf, size_t c,
goto end;
}
- if ((chan_wstream(channel) != NULL && chan_wstream(channel)->closed)
- || (chan_rstream(channel) != NULL && chan_rstream(channel)->closed)) {
- char buf[256];
- snprintf(buf, sizeof(buf),
- "ch %" PRIu64 ": stream closed unexpectedly. "
- "closing channel",
- channel->id);
- call_set_error(channel, buf, WARN_LOG_LEVEL);
- goto end;
- }
-
size_t count = rbuffer_size(rbuf);
DLOG("ch %" PRIu64 ": parsing %u bytes from msgpack Stream: %p",
channel->id, count, stream);
@@ -571,23 +562,6 @@ static Stream *chan_wstream(Channel *chan)
abort();
}
-/// Returns the Stream that a Channel reads from.
-static Stream *chan_rstream(Channel *chan)
-{
- switch (chan->type) {
- case kChannelTypeSocket:
- return &chan->data.stream;
- case kChannelTypeProc:
- return chan->data.proc->out;
- case kChannelTypeStdio:
- return &chan->data.std.in;
- case kChannelTypeInternal:
- return NULL;
- }
- abort();
-}
-
-
static bool channel_write(Channel *channel, WBuffer *buffer)
{
bool success = false;
@@ -799,6 +773,12 @@ static void close_cb(Stream *stream, void *data)
decref(data);
}
+static void close_cb2(Stream *stream, void *data)
+{
+ ILOG("close_cb2");
+ close_channel(data);
+}
+
/// @param source description of source function, rplugin name, TCP addr, etc
static Channel *register_channel(ChannelType type, uint64_t id,
MultiQueue *events, char *source)
2017-08-21 01:04:28 +02:00
Justin M. Keyes
e006b1d98d
log: some DEBUG-level stream logging
2017-08-21 01:04:28 +02:00
Justin M. Keyes
8d1ccb606d
Merge #7193 from justinmk/cb-pathology
2017-08-21 00:46:45 +02:00
Justin M. Keyes
88165a798e
clipboard: test g:clipboard validation, fix a bug
...
Also fix `:help foo` highlighting in health.vim
2017-08-20 22:17:03 +02:00
Justin M. Keyes
cc7e344f83
clipboard: remove start_batch_changes() in redir_write()
...
start_batch_changes() doesn't avoid invoking the clipboard
once-per-line, because the loop is actually in ex_echo(), which calls
redir_write() for each message. But we've already entered
start_batch_changes() by then, so that was never the problem.
redir_write at /home/vagrant/old.neovim/build/../src/nvim/message.c:2523
msg_puts_attr_len at /home/vagrant/old.neovim/build/../src/nvim/message.c:1600
msg_outtrans_len_attr at /home/vagrant/old.neovim/build/../src/nvim/message.c:1221
ex_echo at /home/vagrant/old.neovim/build/../src/nvim/eval.c:19433
do_one_cmd at /home/vagrant/old.neovim/build/../src/nvim/ex_docmd.c:2242
Trying to defer _explicit_ clipboard updates is difficult.
:redir @+ | silent echo system('cat foo') | redir END
is essentially equivalent to:
for l in readfile('foo')
let @+ .= l
endfor
We cannot make judgements about when to ignore a script's bad decisions.
start_batch_changes() only works around the case of clipboard=unnamed,
i.e. _implicit_ clipboard updates (`:g/foo/d`). Not explicit
assignment.
2017-08-20 20:01:22 +02:00
Justin M. Keyes
9882e25dc4
clipboard: avoid error flood during :redir
...
redir_write():
- This is a "batch" operation which was not yet covered by
start_batch_changes()
adjust_clipboard_name():
- msg() and friends during :redir will, of course, cause redir_write()
to try to capture that message, which causes recursion.
- EMSG() here is trouble: if it interrupts :redir it is a mess.
Rather than deal with the mess, show a non-error message.
closes #7182
closes #7184
closes #7183
ref #6048
ref #7032
2017-08-20 19:49:42 +02:00
Justin M. Keyes
b3da396804
Merge #7171 from justinmk/doc
2017-08-19 13:15:12 +02:00
Justin M. Keyes
b13070ec01
doc/api: nvim_out_write() and friends
...
References #7178
2017-08-18 21:43:57 +02:00
Justin M. Keyes
af046a3a81
version: tweak layout, doc
2017-08-18 21:43:57 +02:00
Justin M. Keyes
6ca6a8134d
intro: remove byline #6984
2017-08-18 21:29:01 +02:00
Justin M. Keyes
b2967a0320
nvim -h: omit special-case options
...
Group some options, and sort them alphabetically.
`nvim -h` should fit on one (smallish) screen.
Uncommon options don't need to be here, they live in the :help.
2017-08-18 21:29:01 +02:00
Justin M. Keyes
d7bc55c72d
doc
2017-08-18 21:29:01 +02:00
James McCoy
f465bf0cfa
Merge pull request #7185 from jamessan/fix-provider-clear_stderr
...
provider#clear_stderr: Use remove() not delete() to update s:stderr
2017-08-18 13:56:53 -04:00
James McCoy
3acbb490de
provider#clear_stderr: Use remove() not delete() to update s:stderr
...
Ref #7184
2017-08-18 12:32:49 -04:00
Justin M. Keyes
5b32bce73c
Merge #7007 'Windows :terminal'
...
References #6383
Closes #4748
2017-08-16 21:35:51 +02:00
James McCoy
cea1248f7d
Merge pull request #7052 from ckelsel/vim-8.0.0044
...
vim-patch:8.0.0044
2017-08-16 15:35:22 -04:00
James McCoy
6844ff7561
Merge pull request #7145 from ckelsel/vim-8.0.0174
...
vim-patch:8.0.0174
2017-08-16 15:16:19 -04:00
James McCoy
370602a8f5
Merge pull request #6928 from justinmk/vim-patch-8.0.0678
...
vim-patch:8.0.0678 closing a window does not trigger resizing
2017-08-16 14:49:09 -04:00
ckelsel
8dddf55907
vim-patch:8.0.0044
...
Problem: In diff mode the cursor may end up below the last line, resulting
in an ml_get error.
Solution: Check the line to be valid.
025e3e0baf
2017-08-16 12:48:58 -04:00
James McCoy
8e2096c3df
Merge pull request #7174 from jamessan/appveyor-allow-cov-failure
...
ci: Ignore MINGW_64-gcov failures in overall ci status
2017-08-16 12:43:11 -04:00
Justin M. Keyes
1fb3339844
vim-patch:8.0.0679
...
Problem: Using freed memory.
Solution: Get the parent frame pointer earlier.
41cc038ff8
2017-08-16 12:22:41 -04:00
James McCoy
9a9d9a187f
ci: Ignore MINGW_64-gcov failures in overall ci status
2017-08-16 11:24:12 -04:00
Justin M. Keyes
f0a9b7ff63
vim-patch:8.0.0678 closing a window does not trigger resizing
...
Closes #6748
Problem: When 'equalalways' is set and closing a window in a separate
frame, not all window sizes are adjusted. (Glacambre)
Solution: Resize all windows if the new current window is not in the same
frame as the closed window. (closes vim/vim#1707 )
8eeeba8c02
2017-08-16 10:39:50 -04:00
Justin M. Keyes
9a6eb71eba
test/win: give up on this one
2017-08-16 09:13:45 +02:00
Justin M. Keyes
dbb404542b
test/win: place cursor at edge to tickle SIGWINCH
2017-08-16 09:13:44 +02:00
Justin M. Keyes
91c85a6378
test: tty-test.c: keep tty_out
handle around
...
Now the window_split_tab_spec.lua test seems to work.
Also do some cleanup.
2017-08-16 09:13:44 +02:00
Justin M. Keyes
d2d76882f7
win/test: enable more :terminal tests
...
To deal with SIGWINCH limitations on Windows, change some resize tests
to _shrink_ the screen width. ... But this didn't work, so still
ignoring those tests on Windows.
2017-08-16 09:13:44 +02:00
Justin M. Keyes
e0763e94ad
test: tty-test.c: restore win32 SIGWINCH handler
2017-08-16 09:13:44 +02:00
Justin M. Keyes
6a90f53862
test: cleanup
2017-08-16 09:13:44 +02:00
Justin M. Keyes
8642f05fd9
single-includes: ignore os/pty_process_win.h
2017-08-16 09:13:44 +02:00
erw7
8c1782b840
pty_process_win: avoid quoting for cmd.exe
2017-08-16 09:13:44 +02:00
erw7
d3a8c4f992
win/pty: log errors
2017-08-16 09:13:44 +02:00
erw7
84fb794da6
win/pyt: cleanup
2017-08-16 09:13:44 +02:00
erw7
1614e805b3
win/test: tty-test: print screen size explicitly with CTRL-Q
...
tty-test.exe causes abnormal termination with low repeatability, try
changing it so as not to use SIGWINCH.
2017-08-16 09:13:44 +02:00
erw7
3b992f1688
win/pty: quote_cmd_arg(): check bounds
2017-08-16 09:13:43 +02:00
erw7
e635754e8e
win/pty: jobstart, jobstop: fix null-pointer dereference
...
- Make sure that proc->in is not NULL, because nvim crashed when
starting a job with pty.
- Make sure that proc->out is not NULL, because nvim crashed when stopping
a job opened with pty.
2017-08-16 09:13:43 +02:00
erw7
4b1f21de75
win: support :terminal
2017-08-16 09:13:43 +02:00
Rui Abreu Ferreira
a797856755
win/install: winpty-agent.exe
2017-08-16 09:13:43 +02:00
Ryan Prichard
7f22a27a10
win: integrate winpty (WIP)
...
Handling of process exit is still broken. It detects the moment when the
child process exits, then quickly stops polling for process output. It
should continue polling for output until the agent has scraped all of the
process' output. This problem is easy to notice by running a command like
"dir && exit", but even typing "exit<ENTER>" can manifest the problem --
the "t" might not appear.
winpty's Cygwin adapter handles shutdown by waiting for the agent to close
the CONOUT pipe, which it does after it has scraped the child's last
output. AFAIK, neovim doesn't do anything interesting when winpty closes
the CONOUT pipe.
2017-08-16 09:13:43 +02:00
James McCoy
30cb66e8ba
Merge pull request #7168 from teto/fix_coverty
...
Closes #7149
2017-08-15 19:55:24 -04:00
Justin M. Keyes
bb70eec177
Merge #6364 'command-line color hook'
2017-08-16 00:20:37 +02:00
Matthieu Coudron
1f4090011e
coverty: solve #7149
2017-08-15 21:43:23 +02:00