Skip to content

Commit 9f8c435

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 2052c48 + f79225e commit 9f8c435

29 files changed

+509
-174
lines changed

runtime/doc/eval.txt

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.0. Last change: 2017 Mar 09
1+
*eval.txt* For Vim version 8.0. Last change: 2017 Mar 18
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1986,16 +1986,23 @@ argidx() Number current index in the argument list
19861986
arglistid([{winnr} [, {tabnr}]]) Number argument list id
19871987
argv({nr}) String {nr} entry of the argument list
19881988
argv() List the argument list
1989-
assert_equal({exp}, {act} [, {msg}]) none assert {exp} is equal to {act}
1990-
assert_exception({error} [, {msg}]) none assert {error} is in v:exception
1991-
assert_fails({cmd} [, {error}]) none assert {cmd} fails
1992-
assert_false({actual} [, {msg}]) none assert {actual} is false
1989+
assert_equal({exp}, {act} [, {msg}])
1990+
none assert {exp} is equal to {act}
1991+
assert_exception({error} [, {msg}])
1992+
none assert {error} is in v:exception
1993+
assert_fails({cmd} [, {error}]) none assert {cmd} fails
1994+
assert_false({actual} [, {msg}])
1995+
none assert {actual} is false
19931996
assert_inrange({lower}, {upper}, {actual} [, {msg}])
19941997
none assert {actual} is inside the range
1995-
assert_match({pat}, {text} [, {msg}]) none assert {pat} matches {text}
1996-
assert_notequal({exp}, {act} [, {msg}]) none assert {exp} is not equal {act}
1997-
assert_notmatch({pat}, {text} [, {msg}]) none assert {pat} not matches {text}
1998-
assert_true({actual} [, {msg}]) none assert {actual} is true
1998+
assert_match({pat}, {text} [, {msg}])
1999+
none assert {pat} matches {text}
2000+
assert_notequal({exp}, {act} [, {msg}])
2001+
none assert {exp} is not equal {act}
2002+
assert_notmatch({pat}, {text} [, {msg}])
2003+
none assert {pat} not matches {text}
2004+
assert_report({msg}) none report a test failure
2005+
assert_true({actual} [, {msg}]) none assert {actual} is true
19992006
asin({expr}) Float arc sine of {expr}
20002007
atan({expr}) Float arc tangent of {expr}
20012008
atan2({expr1}, {expr2}) Float arc tangent of {expr1} / {expr2}
@@ -2262,6 +2269,8 @@ remote_peek({serverid} [, {retvar}])
22622269
remote_read({serverid}) String read reply string
22632270
remote_send({server}, {string} [, {idvar}])
22642271
String send key sequence
2272+
remote_startserver({name}) none become server {name}
2273+
String send key sequence
22652274
remove({list}, {idx} [, {end}]) any remove items {idx}-{end} from {list}
22662275
remove({dict}, {key}) any remove entry {key} from {dict}
22672276
rename({from}, {to}) Number rename (move) file from {from} to {to}
@@ -2581,7 +2590,10 @@ assert_notmatch({pattern}, {actual} [, {msg}])
25812590
The opposite of `assert_match()`: add an error message to
25822591
|v:errors| when {pattern} matches {actual}.
25832592

2584-
assert_true({actual} [, {msg}]) *assert_true()*
2593+
assert_report({msg}) *assert_report()*
2594+
Report a test failure directly, using {msg}.
2595+
2596+
assert_true({actual} [, {msg}]) *assert_true()*
25852597
When {actual} is not true an error message is added to
25862598
|v:errors|, like with |assert_equal()|.
25872599
A value is TRUE when it is a non-zero number. When {actual}
@@ -3923,11 +3935,14 @@ foldtext() Returns a String, to be displayed for a closed fold. This is
39233935
|v:foldstart|, |v:foldend| and |v:folddashes| variables.
39243936
The returned string looks like this: >
39253937
+-- 45 lines: abcdef
3926-
< The number of dashes depends on the foldlevel. The "45" is
3927-
the number of lines in the fold. "abcdef" is the text in the
3928-
first non-blank line of the fold. Leading white space, "//"
3929-
or "/*" and the text from the 'foldmarker' and 'commentstring'
3930-
options is removed.
3938+
< The number of leading dashes depends on the foldlevel. The
3939+
"45" is the number of lines in the fold. "abcdef" is the text
3940+
in the first non-blank line of the fold. Leading white space,
3941+
"//" or "/*" and the text from the 'foldmarker' and
3942+
'commentstring' options is removed.
3943+
When used to draw the actual foldtext, the rest of the line
3944+
will be filled with the fold char from the 'fillchars'
3945+
setting.
39313946
{not available when compiled without the |+folding| feature}
39323947

39333948
foldtextresult({lnum}) *foldtextresult()*
@@ -6372,6 +6387,7 @@ remote_send({server}, {string} [, {idvar}])
63726387
See also |clientserver| |RemoteReply|.
63736388
This function is not available in the |sandbox|.
63746389
{only available when compiled with the |+clientserver| feature}
6390+
63756391
Note: Any errors will be reported in the server and may mess
63766392
up the display.
63776393
Examples: >
@@ -6383,6 +6399,12 @@ remote_send({server}, {string} [, {idvar}])
63836399
:echo remote_send("gvim", ":sleep 10 | echo ".
63846400
\ 'server2client(expand("<client>"), "HELLO")<CR>')
63856401
<
6402+
*remote_startserver()* *E941* *E942*
6403+
remote_startserver({name})
6404+
Become the server {name}. This fails if already running as a
6405+
server, when |v:servername| is not empty.
6406+
{only available when compiled with the |+clientserver| feature}
6407+
63866408
remove({list}, {idx} [, {end}]) *remove()*
63876409
Without {end}: Remove the item at {idx} from |List| {list} and
63886410
return the item.

src/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2114,11 +2114,12 @@ test_arglist \
21142114
test_breakindent \
21152115
test_bufwintabinfo \
21162116
test_cdo \
2117+
test_changedtick \
21172118
test_channel \
21182119
test_charsearch \
21192120
test_charsearch_utf8 \
2120-
test_changedtick \
21212121
test_cindent \
2122+
test_clientserver \
21222123
test_cmdline \
21232124
test_command_count \
21242125
test_crypt \

src/eval.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9083,6 +9083,17 @@ assert_bool(typval_T *argvars, int isTrue)
90839083
}
90849084
}
90859085

9086+
void
9087+
assert_report(typval_T *argvars)
9088+
{
9089+
garray_T ga;
9090+
9091+
prepare_assert_error(&ga);
9092+
ga_concat(&ga, get_tv_string(&argvars[0]));
9093+
assert_error(&ga);
9094+
ga_clear(&ga);
9095+
}
9096+
90869097
void
90879098
assert_exception(typval_T *argvars)
90889099
{

src/evalfunc.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static void f_assert_inrange(typval_T *argvars, typval_T *rettv);
5252
static void f_assert_match(typval_T *argvars, typval_T *rettv);
5353
static void f_assert_notequal(typval_T *argvars, typval_T *rettv);
5454
static void f_assert_notmatch(typval_T *argvars, typval_T *rettv);
55+
static void f_assert_report(typval_T *argvars, typval_T *rettv);
5556
static void f_assert_true(typval_T *argvars, typval_T *rettv);
5657
#ifdef FEAT_FLOAT
5758
static void f_asin(typval_T *argvars, typval_T *rettv);
@@ -307,6 +308,7 @@ static void f_remote_foreground(typval_T *argvars, typval_T *rettv);
307308
static void f_remote_peek(typval_T *argvars, typval_T *rettv);
308309
static void f_remote_read(typval_T *argvars, typval_T *rettv);
309310
static void f_remote_send(typval_T *argvars, typval_T *rettv);
311+
static void f_remote_startserver(typval_T *argvars, typval_T *rettv);
310312
static void f_remove(typval_T *argvars, typval_T *rettv);
311313
static void f_rename(typval_T *argvars, typval_T *rettv);
312314
static void f_repeat(typval_T *argvars, typval_T *rettv);
@@ -482,6 +484,7 @@ static struct fst
482484
{"assert_match", 2, 3, f_assert_match},
483485
{"assert_notequal", 2, 3, f_assert_notequal},
484486
{"assert_notmatch", 2, 3, f_assert_notmatch},
487+
{"assert_report", 1, 1, f_assert_report},
485488
{"assert_true", 1, 2, f_assert_true},
486489
#ifdef FEAT_FLOAT
487490
{"atan", 1, 1, f_atan},
@@ -741,6 +744,7 @@ static struct fst
741744
{"remote_peek", 1, 2, f_remote_peek},
742745
{"remote_read", 1, 1, f_remote_read},
743746
{"remote_send", 2, 3, f_remote_send},
747+
{"remote_startserver", 1, 1, f_remote_startserver},
744748
{"remove", 2, 3, f_remove},
745749
{"rename", 2, 2, f_rename},
746750
{"repeat", 2, 2, f_repeat},
@@ -1311,6 +1315,15 @@ f_assert_notmatch(typval_T *argvars, typval_T *rettv UNUSED)
13111315
assert_match_common(argvars, ASSERT_NOTMATCH);
13121316
}
13131317

1318+
/*
1319+
* "assert_report(msg)" function
1320+
*/
1321+
static void
1322+
f_assert_report(typval_T *argvars, typval_T *rettv UNUSED)
1323+
{
1324+
assert_report(argvars);
1325+
}
1326+
13141327
/*
13151328
* "assert_true(actual[, msg])" function
13161329
*/
@@ -8506,7 +8519,7 @@ check_connection(void)
85068519
make_connection();
85078520
if (X_DISPLAY == NULL)
85088521
{
8509-
EMSG(_("E240: No connection to Vim server"));
8522+
EMSG(_("E240: No connection to the X server"));
85108523
return FAIL;
85118524
}
85128525
return OK;
@@ -8716,6 +8729,33 @@ f_remote_send(typval_T *argvars UNUSED, typval_T *rettv)
87168729
#endif
87178730
}
87188731

8732+
/*
8733+
* "remote_startserver()" function
8734+
*/
8735+
static void
8736+
f_remote_startserver(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
8737+
{
8738+
#ifdef FEAT_CLIENTSERVER
8739+
char_u *server = get_tv_string_chk(&argvars[0]);
8740+
8741+
if (server == NULL)
8742+
return; /* type error; errmsg already given */
8743+
if (serverName != NULL)
8744+
EMSG(_("E941: already started a server"));
8745+
else
8746+
{
8747+
# ifdef FEAT_X11
8748+
if (check_connection() == OK)
8749+
serverRegisterName(X_DISPLAY, server);
8750+
# else
8751+
serverSetName(server);
8752+
# endif
8753+
}
8754+
#else
8755+
EMSG(_("E942: +clientserver feature not available"));
8756+
#endif
8757+
}
8758+
87198759
/*
87208760
* "remove()" function
87218761
*/

src/if_xcmdsrv.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -400,27 +400,7 @@ serverSendToVim(
400400

401401
/* Execute locally if no display or target is ourselves */
402402
if (dpy == NULL || (serverName != NULL && STRICMP(name, serverName) == 0))
403-
{
404-
if (asExpr)
405-
{
406-
char_u *ret;
407-
408-
ret = eval_client_expr_to_string(cmd);
409-
if (result != NULL)
410-
{
411-
if (ret == NULL)
412-
*result = vim_strsave((char_u *)_(e_invexprmsg));
413-
else
414-
*result = ret;
415-
}
416-
else
417-
vim_free(ret);
418-
return ret == NULL ? -1 : 0;
419-
}
420-
else
421-
server_to_input_buf(cmd);
422-
return 0;
423-
}
403+
return sendToLocalVim(cmd, asExpr, result);
424404

425405
/*
426406
* Bind the server name to a communication window.
@@ -617,6 +597,10 @@ ServerWait(
617597
if (seconds >= 0 && (now - start) >= seconds)
618598
break;
619599

600+
#ifdef FEAT_TIMERS
601+
check_due_timer();
602+
#endif
603+
620604
/* Just look out for the answer without calling back into Vim */
621605
if (localLoop)
622606
{
@@ -801,6 +785,7 @@ serverSendReply(char_u *name, char_u *str)
801785
WaitForReply(void *p)
802786
{
803787
Window *w = (Window *) p;
788+
804789
return ServerReplyFind(*w, SROP_Find) != NULL;
805790
}
806791

src/main.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4232,6 +4232,11 @@ eval_client_expr_to_string(char_u *expr)
42324232
char_u *res;
42334233
int save_dbl = debug_break_level;
42344234
int save_ro = redir_off;
4235+
void *fc;
4236+
4237+
/* Evaluate the expression at the toplevel, don't use variables local to
4238+
* the calling function. */
4239+
fc = clear_current_funccal();
42354240

42364241
/* Disable debugging, otherwise Vim hangs, waiting for "cont" to be
42374242
* typed. */
@@ -4248,6 +4253,7 @@ eval_client_expr_to_string(char_u *expr)
42484253
--emsg_silent;
42494254
if (emsg_silent < 0)
42504255
emsg_silent = 0;
4256+
restore_current_funccal(fc);
42514257

42524258
/* A client can tell us to redraw, but not to display the cursor, so do
42534259
* that here. */
@@ -4261,6 +4267,41 @@ eval_client_expr_to_string(char_u *expr)
42614267
return res;
42624268
}
42634269

4270+
/*
4271+
* Evaluate a command or expression sent to ourselves.
4272+
*/
4273+
int
4274+
sendToLocalVim(char_u *cmd, int asExpr, char_u **result)
4275+
{
4276+
if (asExpr)
4277+
{
4278+
char_u *ret;
4279+
4280+
ret = eval_client_expr_to_string(cmd);
4281+
if (result != NULL)
4282+
{
4283+
if (ret == NULL)
4284+
{
4285+
char *err = _(e_invexprmsg);
4286+
size_t len = STRLEN(cmd) + STRLEN(err) + 5;
4287+
char_u *msg;
4288+
4289+
msg = alloc(len);
4290+
if (msg != NULL)
4291+
vim_snprintf((char *)msg, len, "%s: \"%s\"", err, cmd);
4292+
*result = msg;
4293+
}
4294+
else
4295+
*result = ret;
4296+
}
4297+
else
4298+
vim_free(ret);
4299+
return ret == NULL ? -1 : 0;
4300+
}
4301+
server_to_input_buf(cmd);
4302+
return 0;
4303+
}
4304+
42644305
/*
42654306
* If conversion is needed, convert "data" from "client_enc" to 'encoding' and
42664307
* return an allocated string. Otherwise return "data".

0 commit comments

Comments
 (0)