1
0
forked from aniani/vim

patch 9.0.1504: no error when calling remote_startserver("")

Problem:    No error when calling remote_startserver() with an empty string.
Solution:   Give an error for an empty string. (Hirohito Higashi,
            closes #12327)
This commit is contained in:
h-east
2023-05-01 22:36:56 +01:00
committed by Bram Moolenaar
parent 2dcfe9ae1d
commit 17b695190d
4 changed files with 19 additions and 17 deletions

View File

@@ -7312,8 +7312,9 @@ remote_send({server}, {string} [, {idvar}])
< <
*remote_startserver()* *E941* *E942* *remote_startserver()* *E941* *E942*
remote_startserver({name}) remote_startserver({name})
Become the server {name}. This fails if already running as a Become the server {name}. {name} must be a non-empty string.
server, when |v:servername| is not empty. This fails if already running as a server, when |v:servername|
is not empty.
Can also be used as a |method|: > Can also be used as a |method|: >
ServerName()->remote_startserver() ServerName()->remote_startserver()

View File

@@ -968,25 +968,23 @@ f_remote_send(typval_T *argvars UNUSED, typval_T *rettv)
f_remote_startserver(typval_T *argvars UNUSED, typval_T *rettv UNUSED) f_remote_startserver(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{ {
#ifdef FEAT_CLIENTSERVER #ifdef FEAT_CLIENTSERVER
char_u *server; if (check_for_nonempty_string_arg(argvars, 0) == FAIL)
if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
return; return;
server = tv_get_string_chk(&argvars[0]);
if (server == NULL)
return; // type error; errmsg already given
if (serverName != NULL) if (serverName != NULL)
emsg(_(e_already_started_server));
else
{ {
emsg(_(e_already_started_server));
return;
}
char_u *server = tv_get_string_chk(&argvars[0]);
# ifdef FEAT_X11 # ifdef FEAT_X11
if (check_connection() == OK) if (check_connection() == OK)
serverRegisterName(X_DISPLAY, server); serverRegisterName(X_DISPLAY, server);
# else # else
serverSetName(server); serverSetName(server);
# endif # endif
}
#else #else
emsg(_(e_clientserver_feature_not_available)); emsg(_(e_clientserver_feature_not_available));
#endif #endif

View File

@@ -182,7 +182,8 @@ func Test_client_server()
endif endif
endtry endtry
call assert_fails('call remote_startserver([])', 'E730:') call assert_fails('call remote_startserver("")', 'E1175:')
call assert_fails('call remote_startserver([])', 'E1174:')
call assert_fails("let x = remote_peek([])", 'E730:') call assert_fails("let x = remote_peek([])", 'E730:')
call assert_fails("let x = remote_read('vim10')", call assert_fails("let x = remote_read('vim10')",
\ has('unix') ? ['E573:.*vim10'] : 'E277:') \ has('unix') ? ['E573:.*vim10'] : 'E277:')

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1504,
/**/ /**/
1503, 1503,
/**/ /**/