summaryrefslogtreecommitdiffstats
path: root/src/channel.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-07-15 19:39:43 +0200
committerBram Moolenaar <Bram@vim.org>2017-07-15 19:39:43 +0200
commitc4da113ef98dcfd6f2a088b1693c0317dcb5bf42 (patch)
treebde8ae5c94f11e87cd89fed4e0c94416b830fedf /src/channel.c
parenta92522fbf3a49d06e08caf010f7d7b0f58d2e131 (diff)
patch 8.0.0716: not easy to start Vim cleanlyv8.0.0716
Problem: Not easy to start Vim cleanly without changing the viminfo file. Not possible to know whether the -i command line flag was used. Solution: Add the --clean command line argument. Add the 'viminfofile' option. Add "-u DEFAULTS".
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/channel.c b/src/channel.c
index ffee334b54..c9e5e144d6 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1438,6 +1438,7 @@ channel_write_in(channel_T *channel)
if (!bufref_valid(&in_part->ch_bufref) || buf->b_ml.ml_mfp == NULL)
{
/* buffer was wiped out or unloaded */
+ ch_log(channel, "input buffer has been wiped out");
in_part->ch_bufref.br_buf = NULL;
return;
}
@@ -2338,7 +2339,7 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
int save_write_to = buffer->b_write_to_channel;
chanpart_T *ch_part = &channel->ch_part[part];
int save_p_ma = buffer->b_p_ma;
- int empty = (buffer->b_ml.ml_flags & ML_EMPTY);
+ int empty = (buffer->b_ml.ml_flags & ML_EMPTY) ? 1 : 0;
if (!buffer->b_p_ma && !ch_part->ch_nomodifiable)
{
@@ -2359,13 +2360,14 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
}
/* Append to the buffer */
- ch_logn(channel, "appending line %d to buffer", (int)lnum + 1);
+ ch_logn(channel, "appending line %d to buffer", (int)lnum + 1 - empty);
buffer->b_p_ma = TRUE;
curbuf = buffer;
+ curwin->w_buffer = curbuf;
u_sync(TRUE);
/* ignore undo failure, undo is not very useful here */
- ignored = u_save(lnum, lnum + 1 + (empty ? 1 : 0));
+ ignored = u_save(lnum - empty, lnum + 1);
if (empty)
{
@@ -2377,6 +2379,7 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel, ch_part_T part)
ml_append(lnum, msg, 0, FALSE);
appended_lines_mark(lnum, 1L);
curbuf = save_curbuf;
+ curwin->w_buffer = curbuf;
if (ch_part->ch_nomodifiable)
buffer->b_p_ma = FALSE;
else
@@ -2483,9 +2486,11 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
}
buffer = ch_part->ch_bufref.br_buf;
- if (buffer != NULL && !bufref_valid(&ch_part->ch_bufref))
+ if (buffer != NULL && (!bufref_valid(&ch_part->ch_bufref)
+ || buffer->b_ml.ml_mfp == NULL))
{
- /* buffer was wiped out */
+ /* buffer was wiped out or unloaded */
+ ch_logs(channel, "%s buffer has been wiped out", part_names[part]);
ch_part->ch_bufref.br_buf = NULL;
buffer = NULL;
}