Compare commits

..

15 Commits

Author SHA1 Message Date
Bram Moolenaar
47015b80a0 patch 8.0.1632: in a terminal dump NUL and space are different
Problem:    In a terminal dump NUL and space considered are different,
            although they are displayed the same.
Solution:   When encountering NUL handle it like space.
2018-03-23 22:10:34 +01:00
Bram Moolenaar
948a796bfe patch 8.0.1631: testing with Vim running in terminal is a bit flaky
Problem:    Testing with Vim running in terminal is a bit flaky.
Solution:   Delete any .swp file so that later tests don't fail.
2018-03-23 20:37:45 +01:00
Bram Moolenaar
295ac5ab5e patch 8.0.1630: trimming white space is not that easy
Problem:    Trimming white space is not that easy.
Solution:   Add the trim() function. (Bukn, closes #1280)
2018-03-22 23:04:02 +01:00
Bram Moolenaar
62b7f6a139 patch 8.0.1629: Mac: getpagesize() is deprecated
Problem:    Mac: getpagesize() is deprecated.
Solution:   Use sysconf() instead. (Ozaki Kiichi, closes #2741)
2018-03-22 21:44:07 +01:00
Bram Moolenaar
0bd052ba12 patch 8.0.1628: channel log doesn't mention exiting
Problem:    Channel log doesn't mention exiting.
Solution:   Add a ch_log() call in getout().
2018-03-22 20:33:56 +01:00
Bram Moolenaar
7735dafb58 patch 8.0.1627: compiler warning for visibility attribute not supported
Problem:    Compiler warning for visibility attribute not supported on MinGW
            builds.
Solution:   Don't add the attribute when we don't expect it to work.
            (Christian Brabandt)
2018-03-22 20:26:50 +01:00
Bram Moolenaar
b571c63d48 patch 8.0.1626: compiler warning for possible loss of data
Problem:    Compiler warning for possible loss of data.
Solution:   Use size_t instead of int. (Christian Brabandt)
2018-03-21 22:27:59 +01:00
Bram Moolenaar
29dfa5af3c patch 8.0.1625: test_quotestar is flaky when run in GTK GUI
Problem:    Test_quotestar is flaky when run in GTK GUI.
Solution:   Do not call lose_selection when invoked from
            selection_clear_event().
2018-03-20 21:24:45 +01:00
Bram Moolenaar
5a3a49ed59 patch 8.0.1624: options for term_dumpdiff() and term_dumpload() not implemented
Problem:    Options for term_dumpdiff() and term_dumpload() not implemented
            yet.
Solution:   Implement the relevant options.
2018-03-20 18:35:53 +01:00
Bram Moolenaar
3e8d385347 patch 8.0.1623: terminal kill tests are flaky
Problem:    Terminal kill tests are flaky.
Solution:   Instead of running Vim in a terminal, run it as a normal command.
2018-03-20 17:43:01 +01:00
Bram Moolenaar
6ed86ad170 patch 8.0.1622: possible NULL pointer dereference
Problem:    Possible NULL pointer dereferencey. (Coverity)
Solution:   Reverse the check for a NULL pointer.
2018-03-20 13:30:42 +01:00
Bram Moolenaar
6185903e3d patch 8.0.1621: using invalid default value for highlight attribute
Problem:    Using invalid default value for highlight attribute.
Solution:   Use zero instead of -1.
2018-03-20 13:00:25 +01:00
Bram Moolenaar
e26e0d2b83 patch 8.0.1620: reading spell file has no good EOF detection
Problem:    Reading spell file has no good EOF detection.
Solution:   Check for EOF at every character read for a length field.
2018-03-20 12:34:04 +01:00
Bram Moolenaar
81c3c89a28 patch 8.0.1619: Win32 GUI: crash when winpty is not installed
Problem:    Win32 GUI: crash when winpty is not installed and trying to use
            :shell in a terminal window.
Solution:   Check for NULL return form term_start(). (Yasuhiro Matsumoto,
            closes #2727)
2018-03-20 11:41:44 +01:00
Bram Moolenaar
ecadf4377f patch 8.0.1618: color Grey50 is missing in the compiled-in table
Problem:    Color Grey50, used for ToolbarLine, is missing in the compiled-in
            table.
Solution:   Add the color to the list. (Kazunobu Kuriyama)
2018-03-20 11:17:04 +01:00
16 changed files with 300 additions and 71 deletions

View File

@@ -1,4 +1,4 @@
*eval.txt* For Vim version 8.0. Last change: 2018 Mar 18
*eval.txt* For Vim version 8.0. Last change: 2018 Mar 20
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2463,6 +2463,7 @@ tolower({expr}) String the String {expr} switched to lowercase
toupper({expr}) String the String {expr} switched to uppercase
tr({src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr}
to chars in {tostr}
trim({text}[, {mask}]) String trim characters in {mask} from {text}
trunc({expr}) Float truncate Float {expr}
type({name}) Number type of variable {name}
undofile({name}) String undo file name for {name}
@@ -8190,7 +8191,20 @@ term_dumpdiff({filename}, {filename} [, {options}])
the second file. The middle part shows the differences.
The parts are separated by a line of dashes.
{options} are not implemented yet.
If the {options} argument is present, it must be a Dict with
these possible members:
"term_name" name to use for the buffer name, instead
of the first file name.
"term_rows" vertical size to use for the terminal,
instead of using 'termsize'
"term_cols" horizontal size to use for the terminal,
instead of using 'termsize'
"vertical" split the window vertically
"curwin" use the current window, do not split the
window; fails if the current buffer
cannot be |abandon|ed
"norestore" do not add the terminal window to a
session file
Each character in the middle part indicates a difference. If
there are multiple differences only the first in this list is
@@ -8213,7 +8227,7 @@ term_dumpload({filename} [, {options}])
Returns the buffer number or zero when it fails.
Also see |terminal-diff|.
{options} are not implemented yet.
For {options} see |term_dumpdiff()|.
*term_dumpwrite()*
term_dumpwrite({buf}, {filename} [, {options}])
@@ -8646,6 +8660,22 @@ tr({src}, {fromstr}, {tostr}) *tr()*
echo tr("<blob>", "<>", "{}")
< returns "{blob}"
trim({text}[, {mask}]) *trim()*
Return {text} as a String where any character in {mask} is
removed from the beginning and end of {text}.
If {mask} is not given, {mask} is all characters up to 0x20,
which includes Tab, space, NL and CR, plus the non-breaking
space character 0xa0.
This code deals with multibyte characters properly.
Examples: >
echo trim(" \r\t\t\r RESERVE \t \t\n\x0B\x0B")."_TAIL"
< returns "RESERVE_TAIL" >
echo trim("needrmvRESERVEnnneeedddrrmmmmvv", "ednmrv")
< returns "RESERVE" >
echo trim("rm<blob1><blob2><any_chars>rrmm<blob1><blob2><blob2>", "rm<blob1><blob2>")
< returns "any_chas"
trunc({expr}) *trunc()*
Return the largest integral value with magnitude less than or
equal to {expr} as a |Float| (truncate towards zero).
@@ -9237,7 +9267,7 @@ visualextra Compiled with extra Visual mode commands.
vms VMS version of Vim.
vreplace Compiled with |gR| and |gr| commands.
vtp Compiled for vcon support |+vtp| (check vcon to find
out if it works in the current console)).
out if it works in the current console).
wildignore Compiled with 'wildignore' option.
wildmenu Compiled with 'wildmenu' option.
win32 Win32 version of Vim (MS-Windows 95 and later, 32 or

View File

@@ -430,6 +430,7 @@ static void f_timer_stopall(typval_T *argvars, typval_T *rettv);
static void f_tolower(typval_T *argvars, typval_T *rettv);
static void f_toupper(typval_T *argvars, typval_T *rettv);
static void f_tr(typval_T *argvars, typval_T *rettv);
static void f_trim(typval_T *argvars, typval_T *rettv);
#ifdef FEAT_FLOAT
static void f_trunc(typval_T *argvars, typval_T *rettv);
#endif
@@ -899,6 +900,7 @@ static struct fst
{"tolower", 1, 1, f_tolower},
{"toupper", 1, 1, f_toupper},
{"tr", 3, 3, f_tr},
{"trim", 1, 2, f_trim},
#ifdef FEAT_FLOAT
{"trunc", 1, 1, f_trunc},
#endif
@@ -5539,7 +5541,7 @@ f_getwinpos(typval_T *argvars UNUSED, typval_T *rettv)
return;
#ifdef FEAT_GUI
if (gui.in_use)
gui_mch_get_winpos(&x, &y);
(void)gui_mch_get_winpos(&x, &y);
# if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
else
# endif
@@ -13203,6 +13205,72 @@ error:
rettv->vval.v_string = ga.ga_data;
}
/*
* "trim({expr})" function
*/
static void
f_trim(typval_T *argvars, typval_T *rettv)
{
char_u buf1[NUMBUFLEN];
char_u buf2[NUMBUFLEN];
char_u *head = get_tv_string_buf_chk(&argvars[0], buf1);
char_u *mask = NULL;
char_u *tail;
char_u *prev;
char_u *p;
int c1;
rettv->v_type = VAR_STRING;
if (head == NULL)
{
rettv->vval.v_string = NULL;
return;
}
if (argvars[1].v_type == VAR_STRING)
mask = get_tv_string_buf_chk(&argvars[1], buf2);
while (*head != NUL)
{
c1 = PTR2CHAR(head);
if (mask == NULL)
{
if (c1 > ' ' && c1 != 0xa0)
break;
}
else
{
for (p = mask; *p != NUL; MB_PTR_ADV(p))
if (c1 == PTR2CHAR(p))
break;
if (*p == NUL)
break;
}
MB_PTR_ADV(head);
}
for (tail = head + STRLEN(head); tail > head; tail = prev)
{
prev = tail;
MB_PTR_BACK(head, prev);
c1 = PTR2CHAR(prev);
if (mask == NULL)
{
if (c1 > ' ' && c1 != 0xa0)
break;
}
else
{
for (p = mask; *p != NUL; MB_PTR_ADV(p))
if (c1 == PTR2CHAR(p))
break;
if (*p == NUL)
break;
}
}
rettv->vval.v_string = vim_strnsave(head, (int)(tail - head));
}
#ifdef FEAT_FLOAT
/*
* "trunc({float})" function

View File

@@ -1366,15 +1366,21 @@ key_release_event(GtkWidget *widget UNUSED,
* Selection handlers:
*/
/* Remember when clip_lose_selection was called from here, we must not call
* gtk_selection_owner_set() then. */
static int in_selection_clear_event = FALSE;
static gint
selection_clear_event(GtkWidget *widget UNUSED,
GdkEventSelection *event,
gpointer user_data UNUSED)
{
in_selection_clear_event = TRUE;
if (event->selection == clip_plus.gtk_sel_atom)
clip_lose_selection(&clip_plus);
else
clip_lose_selection(&clip_star);
in_selection_clear_event = FALSE;
return TRUE;
}
@@ -7048,8 +7054,11 @@ clip_mch_request_selection(VimClipboard *cbd)
void
clip_mch_lose_selection(VimClipboard *cbd UNUSED)
{
gtk_selection_owner_set(NULL, cbd->gtk_sel_atom, gui.event_time);
gui_mch_update();
if (!in_selection_clear_event)
{
gtk_selection_owner_set(NULL, cbd->gtk_sel_atom, gui.event_time);
gui_mch_update();
}
}
/*

View File

@@ -5,7 +5,7 @@
#include <stdarg.h>
#if defined(__GNUC__)
#if defined(__GNUC__) && !defined(__MINGW32__)
# define INTERNAL __attribute__((visibility("internal")))
# define UNUSED __attribute__((unused))
#else

View File

@@ -1389,6 +1389,9 @@ getout(int exitval)
win_T *wp;
exiting = TRUE;
#if defined(FEAT_JOB_CHANNEL)
ch_log(NULL, "Exiting...");
#endif
/* When running in Ex mode an error causes us to exit with a non-zero exit
* code. POSIX requires this, although it's not 100% clear from the

View File

@@ -6148,59 +6148,83 @@ filewritable(char_u *fname)
#if defined(FEAT_SPELL) || defined(FEAT_PERSISTENT_UNDO) || defined(PROTO)
/*
* Read 2 bytes from "fd" and turn them into an int, MSB first.
* Returns -1 when encountering EOF.
*/
int
get2c(FILE *fd)
{
int n;
int c, n;
n = getc(fd);
n = (n << 8) + getc(fd);
return n;
if (n == EOF) return -1;
c = getc(fd);
if (c == EOF) return -1;
return (n << 8) + c;
}
/*
* Read 3 bytes from "fd" and turn them into an int, MSB first.
* Returns -1 when encountering EOF.
*/
int
get3c(FILE *fd)
{
int n;
int c, n;
n = getc(fd);
n = (n << 8) + getc(fd);
n = (n << 8) + getc(fd);
return n;
if (n == EOF) return -1;
c = getc(fd);
if (c == EOF) return -1;
n = (n << 8) + c;
c = getc(fd);
if (c == EOF) return -1;
return (n << 8) + c;
}
/*
* Read 4 bytes from "fd" and turn them into an int, MSB first.
* Returns -1 when encountering EOF.
*/
int
get4c(FILE *fd)
{
int c;
/* Use unsigned rather than int otherwise result is undefined
* when left-shift sets the MSB. */
unsigned n;
n = (unsigned)getc(fd);
n = (n << 8) + (unsigned)getc(fd);
n = (n << 8) + (unsigned)getc(fd);
n = (n << 8) + (unsigned)getc(fd);
c = getc(fd);
if (c == EOF) return -1;
n = (unsigned)c;
c = getc(fd);
if (c == EOF) return -1;
n = (n << 8) + (unsigned)c;
c = getc(fd);
if (c == EOF) return -1;
n = (n << 8) + (unsigned)c;
c = getc(fd);
if (c == EOF) return -1;
n = (n << 8) + (unsigned)c;
return (int)n;
}
/*
* Read 8 bytes from "fd" and turn them into a time_T, MSB first.
* Returns -1 when encountering EOF.
*/
time_T
get8ctime(FILE *fd)
{
int c;
time_T n = 0;
int i;
for (i = 0; i < 8; ++i)
n = (n << 8) + getc(fd);
{
c = getc(fd);
if (c == EOF) return -1;
n = (n << 8) + c;
}
return n;
}

View File

@@ -603,7 +603,7 @@ mch_total_mem(int special UNUSED)
# ifdef MAC_OS_X_VERSION_10_9
+ vm_stat.compressor_page_count
# endif
) * getpagesize();
) * sysconf(_SC_PAGESIZE);
mach_port_deallocate(mach_task_self(), host);
}
# endif

View File

@@ -4824,6 +4824,8 @@ mch_call_shell_terminal(
argvar[0].vval.v_string = newcmd;
argvar[1].v_type = VAR_UNKNOWN;
buf = term_start(argvar, NULL, &opt, TERM_START_SYSTEM);
if (buf == NULL)
return 255;
/* Find a window to make "buf" curbuf. */
aucmd_prepbuf(&aco, buf);

View File

@@ -4256,7 +4256,7 @@ ex_vimgrep(exarg_T *eap)
goto theend;
}
if (s != NULL && *s == NUL)
if (s == NULL || *s == NUL)
{
/* Pattern is empty, use last search pattern. */
if (last_search_pat() == NULL)

View File

@@ -10044,11 +10044,11 @@ highlight_changed(void)
#ifdef USER_HIGHLIGHT
char_u userhl[10];
# ifdef FEAT_STL_OPT
int id_SNC = -1;
int id_S = -1;
int id_SNC = 0;
# ifdef FEAT_TERMINAL
int id_ST = -1;
int id_STNC = -1;
int id_ST = 0;
int id_STNC = 0;
# endif
int hlcnt;
# endif

View File

@@ -3642,7 +3642,7 @@ swapping_screen(void)
return (full_screen && *T_TI != NUL);
}
#ifdef FEAT_MOUSE
#if defined(FEAT_MOUSE) || defined(PROTO)
/*
* setmouse() - switch mouse on/off depending on current mode and 'mouse'
*/
@@ -6805,6 +6805,7 @@ gui_get_color_cmn(char_u *name)
{(char_u *)"green", RGB(0x00, 0xFF, 0x00)},
{(char_u *)"grey", RGB(0xBE, 0xBE, 0xBE)},
{(char_u *)"grey40", RGB(0x66, 0x66, 0x66)},
{(char_u *)"grey50", RGB(0x7F, 0x7F, 0x7F)},
{(char_u *)"grey90", RGB(0xE5, 0xE5, 0xE5)},
{(char_u *)"lightblue", RGB(0xAD, 0xD8, 0xE6)},
{(char_u *)"lightcyan", RGB(0xE0, 0xFF, 0xFF)},

View File

@@ -342,6 +342,7 @@ term_start(
buf_T *old_curbuf = NULL;
int res;
buf_T *newbuf;
int vertical = opt->jo_vertical || (cmdmod.split & WSP_VERT);
if (check_restricted() || check_secure())
return NULL;
@@ -411,17 +412,19 @@ term_start(
split_ea.cmdidx = CMD_new;
split_ea.cmd = (char_u *)"new";
split_ea.arg = (char_u *)"";
if (opt->jo_term_rows > 0 && !(cmdmod.split & WSP_VERT))
if (opt->jo_term_rows > 0 && !vertical)
{
split_ea.line2 = opt->jo_term_rows;
split_ea.addr_count = 1;
}
if (opt->jo_term_cols > 0 && (cmdmod.split & WSP_VERT))
if (opt->jo_term_cols > 0 && vertical)
{
split_ea.line2 = opt->jo_term_cols;
split_ea.addr_count = 1;
}
if (vertical)
cmdmod.split |= WSP_VERT;
ex_splitview(&split_ea);
if (curwin == old_curwin)
{
@@ -437,11 +440,9 @@ term_start(
{
/* Only one size was taken care of with :new, do the other one. With
* "curwin" both need to be done. */
if (opt->jo_term_rows > 0 && (opt->jo_curwin
|| (cmdmod.split & WSP_VERT)))
if (opt->jo_term_rows > 0 && (opt->jo_curwin || vertical))
win_setheight(opt->jo_term_rows);
if (opt->jo_term_cols > 0 && (opt->jo_curwin
|| !(cmdmod.split & WSP_VERT)))
if (opt->jo_term_cols > 0 && (opt->jo_curwin || !vertical))
win_setwidth(opt->jo_term_cols);
}
@@ -3395,6 +3396,15 @@ f_term_dumpwrite(typval_T *argvars, typval_T *rettv UNUSED)
for (i = 0; i < VTERM_MAX_CHARS_PER_CELL; ++i)
{
int c = cell.chars[i];
int pc = prev_cell.chars[i];
/* For the first character NUL is the same as space. */
if (i == 0)
{
c = (c == NUL) ? ' ' : c;
pc = (pc == NUL) ? ' ' : pc;
}
if (cell.chars[i] != prev_cell.chars[i])
same_chars = FALSE;
if (cell.chars[i] == NUL || prev_cell.chars[i] == NUL)
@@ -3732,6 +3742,7 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
char_u buf2[NUMBUFLEN];
char_u *fname1;
char_u *fname2 = NULL;
char_u *fname_tofree = NULL;
FILE *fd1;
FILE *fd2 = NULL;
char_u *textline = NULL;
@@ -3763,10 +3774,23 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
}
init_job_options(&opt);
/* TODO: use the {options} argument */
if (argvars[do_diff ? 2 : 1].v_type != VAR_UNKNOWN
&& get_job_options(&argvars[do_diff ? 2 : 1], &opt, 0,
JO2_TERM_NAME + JO2_TERM_COLS + JO2_TERM_ROWS
+ JO2_VERTICAL + JO2_CURWIN + JO2_NORESTORE) == FAIL)
goto theend;
/* TODO: use the file name arguments for the buffer name */
opt.jo_term_name = (char_u *)"dump diff";
if (opt.jo_term_name == NULL)
{
size_t len = STRLEN(fname1) + 12;
fname_tofree = alloc((int)len);
if (fname_tofree != NULL)
{
vim_snprintf((char *)fname_tofree, len, "dump diff %s", fname1);
opt.jo_term_name = fname_tofree;
}
}
buf = term_start(&argvars[0], NULL, &opt, TERM_START_NOJOB);
if (buf != NULL && buf->b_term != NULL)
@@ -3937,6 +3961,7 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
theend:
vim_free(textline);
vim_free(fname_tofree);
fclose(fd1);
if (fd2 != NULL)
fclose(fd2);
@@ -4541,8 +4566,6 @@ f_term_start(typval_T *argvars, typval_T *rettv)
+ JO2_NORESTORE + JO2_TERM_KILL) == FAIL)
return;
if (opt.jo_vertical)
cmdmod.split = WSP_VERT;
buf = term_start(&argvars[0], NULL, &opt, 0);
if (buf != NULL && buf->b_term != NULL)

View File

@@ -26,6 +26,10 @@ source shared.vim
"
" Options is a dictionary (not used yet).
func RunVimInTerminal(arguments, options)
" If Vim doesn't exit a swap file remains, causing other tests to fail.
" Remove it here.
call delete(".swp")
" Make a horizontal and vertical split, so that we can get exactly the right
" size terminal window. Works only when we currently have one window.
call assert_equal(1, winnr('$'))

View File

@@ -876,3 +876,26 @@ func Test_shellescape()
let &shell = save_shell
endfunc
func Test_trim()
call assert_equal("Testing", trim(" \t\r\r\x0BTesting \t\n\r\n\t\x0B\x0B"))
call assert_equal("Testing", trim(" \t \r\r\n\n\x0BTesting \t\n\r\n\t\x0B\x0B"))
call assert_equal("RESERVE", trim("xyz \twwRESERVEzyww \t\t", " wxyz\t"))
call assert_equal("wRE \tSERVEzyww", trim("wRE \tSERVEzyww"))
call assert_equal("abcd\t xxxx tail", trim(" \tabcd\t xxxx tail"))
call assert_equal("\tabcd\t xxxx tail", trim(" \tabcd\t xxxx tail", " "))
call assert_equal(" \tabcd\t xxxx tail", trim(" \tabcd\t xxxx tail", "abx"))
call assert_equal("RESERVE", trim("你RESERVE好", "你好"))
call assert_equal("您R E SER V E早", trim("你好您R E SER V E早好你你", "你好"))
call assert_equal("你好您R E SER V E早好你你", trim(" \n\r\r 你好您R E SER V E早好你你 \t \x0B", ))
call assert_equal("您R E SER V E早好你你 \t \x0B", trim(" 你好您R E SER V E早好你你 \t \x0B", " 你好"))
call assert_equal("您R E SER V E早好你你 \t \x0B", trim(" tteesstttt你好您R E SER V E早好你你 \t \x0B ttestt", " 你好tes"))
call assert_equal("您R E SER V E早好你你 \t \x0B", trim(" tteesstttt你好您R E SER V E早好你你 \t \x0B ttestt", " 你你你好好好tttsses"))
call assert_equal("留下", trim("这些些不要这些留下这些", "这些不要"))
call assert_equal("", trim("", ""))
call assert_equal("a", trim("a", ""))
call assert_equal("", trim("", "a"))
let chars = join(map(range(1, 0x20) + [0xa0], {n -> nr2char(n)}), '')
call assert_equal("x", trim(chars . "x" . chars))
endfunc

View File

@@ -855,49 +855,61 @@ func Test_terminal_response_to_control_sequence()
unlet g:job
endfunc
" Run Vim in a terminal, then start a terminal in that Vim with a kill
" argument, check that :qall works.
func Test_terminal_qall_kill_arg()
if !CanRunVimInTerminal()
" Run Vim, start a terminal in that Vim with the kill argument,
" :qall works.
func Run_terminal_qall_kill(line1, line2)
" 1. Open a terminal window and wait for the prompt to appear
" 2. set kill using term_setkill()
" 3. make Vim exit, it will kill the shell
let after = [
\ a:line1,
\ 'let buf = bufnr("%")',
\ 'while term_getline(buf, 1) =~ "^\\s*$"',
\ ' sleep 10m',
\ 'endwhile',
\ a:line2,
\ 'au VimLeavePre * call writefile(["done"], "Xdone")',
\ 'qall',
\ ]
if !RunVim([], after, '')
return
endif
let buf = RunVimInTerminal('', {})
" Open a terminal window and wait for the prompt to appear
call term_sendkeys(buf, ":term ++kill=kill\<CR>")
call WaitFor({-> term_getline(buf, 10) =~ '\[running]'})
call WaitFor({-> term_getline(buf, 1) !~ '^\s*$'})
" make Vim exit, it will kill the shell
call term_sendkeys(buf, "\<C-W>:qall\<CR>")
call WaitFor({-> term_getstatus(buf) == "finished"})
" close the terminal window where Vim was running
quit
call assert_equal("done", readfile("Xdone")[0])
call delete("Xdone")
endfunc
" Run Vim in a terminal, then start a terminal in that Vim with a kill
" argument, check that :qall works.
func Test_terminal_qall_kill_arg()
call Run_terminal_qall_kill('term ++kill=kill', '')
endfunc
" Run Vim, start a terminal in that Vim, set the kill argument with
" term_setkill(), check that :qall works.
func Test_terminal_qall_kill_func()
if !CanRunVimInTerminal()
call Run_terminal_qall_kill('term', 'call term_setkill(buf, "kill")')
endfunc
" Run Vim, start a terminal in that Vim without the kill argument,
" check that :qall does not exit, :qall! does.
func Test_terminal_qall_exit()
let after = [
\ 'term',
\ 'let buf = bufnr("%")',
\ 'while term_getline(buf, 1) =~ "^\\s*$"',
\ ' sleep 10m',
\ 'endwhile',
\ 'set nomore',
\ 'au VimLeavePre * call writefile(["too early"], "Xdone")',
\ 'qall',
\ 'au! VimLeavePre * exe buf . "bwipe!" | call writefile(["done"], "Xdone")',
\ 'cquit',
\ ]
if !RunVim([], after, '')
return
endif
let buf = RunVimInTerminal('', {})
" Open a terminal window and wait for the prompt to appear
call term_sendkeys(buf, ":term\<CR>")
call WaitFor({-> term_getline(buf, 10) =~ '\[running]'})
call WaitFor({-> term_getline(buf, 1) !~ '^\s*$'})
" set kill using term_setkill()
call term_sendkeys(buf, "\<C-W>:call term_setkill(bufnr('%'), 'kill')\<CR>")
" make Vim exit, it will kill the shell
call term_sendkeys(buf, "\<C-W>:qall\<CR>")
call WaitFor({-> term_getstatus(buf) == "finished"})
" close the terminal window where Vim was running
quit
call assert_equal("done", readfile("Xdone")[0])
call delete("Xdone")
endfunc
" Run Vim in a terminal, then start a terminal in that Vim without a kill

View File

@@ -766,6 +766,36 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1632,
/**/
1631,
/**/
1630,
/**/
1629,
/**/
1628,
/**/
1627,
/**/
1626,
/**/
1625,
/**/
1624,
/**/
1623,
/**/
1622,
/**/
1621,
/**/
1620,
/**/
1619,
/**/
1618,
/**/
1617,
/**/