mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-07 15:37:14 +02:00
Merge remote-tracking branch 'vim/master'
This commit is contained in:
@@ -163,6 +163,9 @@ Use |ch_status()| to see if the channel could be opened.
|
||||
The "close_cb" is also considered for this.
|
||||
"never" All messages will be kept.
|
||||
|
||||
*channel-noblock*
|
||||
"noblock" Same effect as |job-noblock|. Only matters for writing.
|
||||
|
||||
*waittime*
|
||||
"waittime" The time to wait for the connection to be made in
|
||||
milliseconds. A negative number waits forever.
|
||||
@@ -594,6 +597,17 @@ See |job_setoptions()| and |ch_setoptions()|.
|
||||
Note: when writing to a file or buffer and when
|
||||
reading from a buffer NL mode is used by default.
|
||||
|
||||
*job-noblock*
|
||||
"noblock": 1 When writing use a non-blocking write call. This
|
||||
avoids getting stuck if Vim should handle other
|
||||
messages in between, e.g. when a job sends back data
|
||||
to Vim. It implies that when `ch_sendraw()` returns
|
||||
not all data may have been written yet.
|
||||
This option was added in patch 8.1.0350, test with: >
|
||||
if has("patch-8.1.350")
|
||||
let options['noblock'] = 1
|
||||
endif
|
||||
<
|
||||
*job-callback*
|
||||
"callback": handler Callback for something to read on any part of the
|
||||
channel.
|
||||
|
||||
@@ -8737,6 +8737,7 @@ test_override({name}, {val}) *test_override()*
|
||||
|
||||
name effect when {val} is non-zero ~
|
||||
redraw disable the redrawing() function
|
||||
redraw_flag ignore the RedrawingDisabled flag
|
||||
char_avail disable the char_avail() function
|
||||
starting reset the "starting" variable, see below
|
||||
nfa_fail makes the NFA regexp engine fail to force a
|
||||
|
||||
+11
-1
@@ -1206,6 +1206,7 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
|
||||
channel->ch_part[PART_OUT].ch_mode = opt->jo_out_mode;
|
||||
if (opt->jo_set & JO_ERR_MODE)
|
||||
channel->ch_part[PART_ERR].ch_mode = opt->jo_err_mode;
|
||||
channel->ch_nonblock = opt->jo_noblock;
|
||||
|
||||
if (opt->jo_set & JO_TIMEOUT)
|
||||
for (part = PART_SOCK; part < PART_COUNT; ++part)
|
||||
@@ -3719,7 +3720,7 @@ channel_any_keep_open()
|
||||
channel_set_nonblock(channel_T *channel, ch_part_T part)
|
||||
{
|
||||
chanpart_T *ch_part = &channel->ch_part[part];
|
||||
int fd = ch_part->ch_fd;
|
||||
int fd = ch_part->ch_fd;
|
||||
|
||||
if (fd != INVALID_FD)
|
||||
{
|
||||
@@ -3764,6 +3765,9 @@ channel_send(
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (channel->ch_nonblock && !ch_part->ch_nonblocking)
|
||||
channel_set_nonblock(channel, part);
|
||||
|
||||
if (ch_log_active())
|
||||
{
|
||||
ch_log_lead("SEND ", channel, part);
|
||||
@@ -4595,6 +4599,12 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
|
||||
== FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
else if (STRCMP(hi->hi_key, "noblock") == 0)
|
||||
{
|
||||
if (!(supported & JO_MODE))
|
||||
break;
|
||||
opt->jo_noblock = get_tv_number(item);
|
||||
}
|
||||
else if (STRCMP(hi->hi_key, "in_io") == 0
|
||||
|| STRCMP(hi->hi_key, "out_io") == 0
|
||||
|| STRCMP(hi->hi_key, "err_io") == 0)
|
||||
|
||||
@@ -13104,6 +13104,8 @@ f_test_override(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
|
||||
if (STRCMP(name, (char_u *)"redraw") == 0)
|
||||
disable_redraw_for_testing = val;
|
||||
else if (STRCMP(name, (char_u *)"redraw_flag") == 0)
|
||||
ignore_redraw_flag_for_testing = val;
|
||||
else if (STRCMP(name, (char_u *)"char_avail") == 0)
|
||||
disable_char_avail_for_testing = val;
|
||||
else if (STRCMP(name, (char_u *)"starting") == 0)
|
||||
@@ -13126,6 +13128,7 @@ f_test_override(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
disable_char_avail_for_testing = FALSE;
|
||||
disable_redraw_for_testing = FALSE;
|
||||
ignore_redraw_flag_for_testing = FALSE;
|
||||
nfa_fail_for_testing = FALSE;
|
||||
if (save_starting >= 0)
|
||||
{
|
||||
|
||||
+3
-1
@@ -2918,6 +2918,7 @@ free_cmdmod(void)
|
||||
|
||||
/*
|
||||
* Parse the address range, if any, in "eap".
|
||||
* May set the last search pattern.
|
||||
* Return FAIL and set "errormsg" or return OK.
|
||||
*/
|
||||
int
|
||||
@@ -4452,10 +4453,11 @@ skip_range(
|
||||
}
|
||||
|
||||
/*
|
||||
* get a single EX address
|
||||
* Get a single EX address.
|
||||
*
|
||||
* Set ptr to the next character after the part that was interpreted.
|
||||
* Set ptr to NULL when an error is encountered.
|
||||
* This may set the last used search pattern.
|
||||
*
|
||||
* Return MAXLNUM when no Ex address was found.
|
||||
*/
|
||||
|
||||
+21
-2
@@ -271,6 +271,7 @@ set_search_match(pos_T *t)
|
||||
/*
|
||||
* Return TRUE when 'incsearch' highlighting is to be done.
|
||||
* Sets search_first_line and search_last_line to the address range.
|
||||
* May change the last search pattern.
|
||||
*/
|
||||
static int
|
||||
do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
|
||||
@@ -470,8 +471,12 @@ may_do_incsearch_highlighting(
|
||||
int next_char;
|
||||
int use_last_pat;
|
||||
|
||||
// Parsing range may already set the last search pattern.
|
||||
save_last_search_pattern();
|
||||
|
||||
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
|
||||
{
|
||||
restore_last_search_pattern();
|
||||
finish_incsearch_highlighting(FALSE, is_state, TRUE);
|
||||
return;
|
||||
}
|
||||
@@ -479,6 +484,7 @@ may_do_incsearch_highlighting(
|
||||
// If there is a character waiting, search and redraw later.
|
||||
if (char_avail())
|
||||
{
|
||||
restore_last_search_pattern();
|
||||
is_state->incsearch_postponed = TRUE;
|
||||
return;
|
||||
}
|
||||
@@ -493,7 +499,6 @@ may_do_incsearch_highlighting(
|
||||
curwin->w_cursor.lnum = search_first_line;
|
||||
curwin->w_cursor.col = 0;
|
||||
}
|
||||
save_last_search_pattern();
|
||||
|
||||
// Use the previous pattern for ":s//".
|
||||
next_char = ccline.cmdbuff[skiplen + patlen];
|
||||
@@ -627,10 +632,19 @@ may_adjust_incsearch_highlighting(
|
||||
int i;
|
||||
int save;
|
||||
|
||||
// Parsing range may already set the last search pattern.
|
||||
save_last_search_pattern();
|
||||
|
||||
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
|
||||
{
|
||||
restore_last_search_pattern();
|
||||
return OK;
|
||||
}
|
||||
if (patlen == 0 && ccline.cmdbuff[skiplen] == NUL)
|
||||
{
|
||||
restore_last_search_pattern();
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (firstc == ccline.cmdbuff[skiplen])
|
||||
{
|
||||
@@ -641,7 +655,6 @@ may_adjust_incsearch_highlighting(
|
||||
else
|
||||
pat = ccline.cmdbuff + skiplen;
|
||||
|
||||
save_last_search_pattern();
|
||||
cursor_off();
|
||||
out_flush();
|
||||
if (c == Ctrl_G)
|
||||
@@ -721,8 +734,14 @@ may_add_char_to_search(int firstc, int *c, incsearch_state_T *is_state)
|
||||
{
|
||||
int skiplen, patlen;
|
||||
|
||||
// Parsing range may already set the last search pattern.
|
||||
save_last_search_pattern();
|
||||
|
||||
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
|
||||
{
|
||||
restore_last_search_pattern();
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// Add a character from under the cursor for 'incsearch'.
|
||||
if (is_state->did_incsearch)
|
||||
|
||||
+4
-3
@@ -1638,9 +1638,10 @@ EXTERN int alloc_fail_countdown INIT(= -1);
|
||||
EXTERN int alloc_fail_repeat INIT(= 0);
|
||||
|
||||
/* flags set by test_override() */
|
||||
EXTERN int disable_char_avail_for_testing INIT(= 0);
|
||||
EXTERN int disable_redraw_for_testing INIT(= 0);
|
||||
EXTERN int nfa_fail_for_testing INIT(= 0);
|
||||
EXTERN int disable_char_avail_for_testing INIT(= FALSE);
|
||||
EXTERN int disable_redraw_for_testing INIT(= FALSE);
|
||||
EXTERN int ignore_redraw_flag_for_testing INIT(= FALSE);
|
||||
EXTERN int nfa_fail_for_testing INIT(= FALSE);
|
||||
|
||||
EXTERN int in_free_unref_items INIT(= FALSE);
|
||||
#endif
|
||||
|
||||
+8
-4
@@ -417,10 +417,14 @@ mch_inchar(
|
||||
handle_resize();
|
||||
|
||||
#ifdef MESSAGE_QUEUE
|
||||
parse_queued_messages();
|
||||
/* If input was put directly in typeahead buffer bail out here. */
|
||||
if (typebuf_changed(tb_change_cnt))
|
||||
return 0;
|
||||
// Only process messages when waiting.
|
||||
if (wtime != 0)
|
||||
{
|
||||
parse_queued_messages();
|
||||
// If input was put directly in typeahead buffer bail out here.
|
||||
if (typebuf_changed(tb_change_cnt))
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if (wtime < 0 && did_start_blocking)
|
||||
/* blocking and already waited for p_ut */
|
||||
|
||||
+7
-3
@@ -1529,15 +1529,19 @@ WaitForChar(long msec, int ignore_input)
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
// Only process messages when waiting.
|
||||
if (msec != 0)
|
||||
{
|
||||
#ifdef MESSAGE_QUEUE
|
||||
parse_queued_messages();
|
||||
parse_queued_messages();
|
||||
#endif
|
||||
#ifdef FEAT_MZSCHEME
|
||||
mzvim_check_threads();
|
||||
mzvim_check_threads();
|
||||
#endif
|
||||
#ifdef FEAT_CLIENTSERVER
|
||||
serverProcessPendingMessages();
|
||||
serverProcessPendingMessages();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (0
|
||||
#ifdef FEAT_MOUSE
|
||||
|
||||
+5
-2
@@ -10869,8 +10869,11 @@ redrawing(void)
|
||||
return 0;
|
||||
else
|
||||
#endif
|
||||
return (!RedrawingDisabled
|
||||
&& !(p_lz && char_avail() && !KeyTyped && !do_redraw));
|
||||
return ((!RedrawingDisabled
|
||||
#ifdef FEAT_EVAL
|
||||
|| ignore_redraw_flag_for_testing
|
||||
#endif
|
||||
) && !(p_lz && char_avail() && !KeyTyped && !do_redraw));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1654,6 +1654,7 @@ struct channel_S {
|
||||
partial_T *ch_close_partial;
|
||||
int ch_drop_never;
|
||||
int ch_keep_open; /* do not close on read error */
|
||||
int ch_nonblock;
|
||||
|
||||
job_T *ch_job; /* Job that uses this channel; this does not
|
||||
* count as a reference to avoid a circular
|
||||
@@ -1732,6 +1733,7 @@ typedef struct
|
||||
ch_mode_T jo_in_mode;
|
||||
ch_mode_T jo_out_mode;
|
||||
ch_mode_T jo_err_mode;
|
||||
int jo_noblock;
|
||||
|
||||
job_io_T jo_io[4]; /* PART_OUT, PART_ERR, PART_IN */
|
||||
char_u jo_io_name_buf[4][NUMBUFLEN];
|
||||
|
||||
@@ -47,8 +47,11 @@ endfunc
|
||||
func Ch_communicate(port)
|
||||
" Avoid dropping messages, since we don't use a callback here.
|
||||
let s:chopt.drop = 'never'
|
||||
" Also add the noblock flag to try it out.
|
||||
let s:chopt.noblock = 1
|
||||
let handle = ch_open('localhost:' . a:port, s:chopt)
|
||||
unlet s:chopt.drop
|
||||
unlet s:chopt.noblock
|
||||
if ch_status(handle) == "fail"
|
||||
call assert_report("Can't open channel")
|
||||
return
|
||||
@@ -451,8 +454,9 @@ func Test_raw_pipe()
|
||||
call ch_log('Test_raw_pipe()')
|
||||
" Add a dummy close callback to avoid that messages are dropped when calling
|
||||
" ch_canread().
|
||||
" Also test the non-blocking option.
|
||||
let job = job_start(s:python . " test_channel_pipe.py",
|
||||
\ {'mode': 'raw', 'drop': 'never'})
|
||||
\ {'mode': 'raw', 'drop': 'never', 'noblock': 1})
|
||||
call assert_equal(v:t_job, type(job))
|
||||
call assert_equal("run", job_status(job))
|
||||
|
||||
@@ -1350,6 +1354,34 @@ endfunc
|
||||
|
||||
""""""""""
|
||||
|
||||
function ExitCbWipe(job, status)
|
||||
exe g:wipe_buf 'bw!'
|
||||
endfunction
|
||||
|
||||
" This caused a crash, because messages were handled while peeking for a
|
||||
" character.
|
||||
func Test_exit_cb_wipes_buf()
|
||||
if !has('timers')
|
||||
return
|
||||
endif
|
||||
set cursorline lazyredraw
|
||||
call test_override('redraw_flag', 1)
|
||||
new
|
||||
let g:wipe_buf = bufnr('')
|
||||
|
||||
let job = job_start(['true'], {'exit_cb': 'ExitCbWipe'})
|
||||
let timer = timer_start(300, {-> feedkeys("\<Esc>", 'nt')}, {'repeat': 5})
|
||||
call feedkeys(repeat('g', 1000) . 'o', 'ntx!')
|
||||
call WaitForAssert({-> assert_equal("dead", job_status(job))})
|
||||
call timer_stop(timer)
|
||||
|
||||
set nocursorline nolazyredraw
|
||||
unlet g:wipe_buf
|
||||
call test_override('ALL', 0)
|
||||
endfunc
|
||||
|
||||
""""""""""
|
||||
|
||||
let g:Ch_unletResponse = ''
|
||||
func s:UnletHandler(handle, msg)
|
||||
let g:Ch_unletResponse = a:msg
|
||||
|
||||
@@ -1043,6 +1043,23 @@ func Test_incsearch_vimgrep_dump()
|
||||
call delete('Xis_vimgrep_script')
|
||||
endfunc
|
||||
|
||||
func Test_keep_last_search_pattern()
|
||||
if !exists('+incsearch')
|
||||
return
|
||||
endif
|
||||
new
|
||||
call setline(1, ['foo', 'foo', 'foo'])
|
||||
set incsearch
|
||||
call test_override("char_avail", 1)
|
||||
let @/ = 'bar'
|
||||
call feedkeys(":/foo/s//\<Esc>", 'ntx')
|
||||
call assert_equal('bar', @/)
|
||||
|
||||
bwipe!
|
||||
call test_override("ALL", 0)
|
||||
set noincsearch
|
||||
endfunc
|
||||
|
||||
func Test_search_undefined_behaviour()
|
||||
if !has("terminal")
|
||||
return
|
||||
|
||||
@@ -809,6 +809,12 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
351,
|
||||
/**/
|
||||
350,
|
||||
/**/
|
||||
349,
|
||||
/**/
|
||||
348,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user