patch 9.0.0977: it is not easy to see what client-server commands are doing
Problem: It is not easy to see what client-server commands are doing.
Solution: Add channel log messages if ch_log() is available. Move the
channel logging and make it available with the +eval feature.
diff --git a/src/if_xcmdsrv.c b/src/if_xcmdsrv.c
index 1f6b8d2..1aa09fd 100644
--- a/src/if_xcmdsrv.c
+++ b/src/if_xcmdsrv.c
@@ -388,11 +388,12 @@
if (name == NULL || *name == NUL)
name = (char_u *)"GVIM"; // use a default name
- if (commProperty == None && dpy != NULL)
- {
- if (SendInit(dpy) < 0)
- return -1;
- }
+ if (commProperty == None && dpy != NULL && SendInit(dpy) < 0)
+ return -1;
+
+#if defined(FEAT_EVAL)
+ ch_log(NULL, "serverSendToVim(%s, %s)", name, cmd);
+#endif
// Execute locally if no display or target is ourselves
if (dpy == NULL || (serverName != NULL && STRICMP(name, serverName) == 0))
@@ -494,6 +495,11 @@
break;
}
}
+
+#if defined(FEAT_EVAL)
+ ch_log(NULL, "serverSendToVim() result: %s",
+ pending.result == NULL ? "NULL" : (char *)pending.result);
+#endif
if (result != NULL)
*result = pending.result;
else
@@ -1221,6 +1227,10 @@
int code;
char_u *tofree;
+#if defined(FEAT_EVAL)
+ ch_log(NULL, "server_parse_message() numItems: %ld", numItems);
+#endif
+
/*
* Several commands and results could arrive in the property at
* one time; each iteration through the outer loop handles a
@@ -1240,7 +1250,7 @@
continue;
}
- if ((*p == 'c' || *p == 'k') && (p[1] == 0))
+ if ((*p == 'c' || *p == 'k') && p[1] == 0)
{
Window resWindow;
char_u *name, *script, *serial, *end;
@@ -1261,6 +1271,9 @@
enc = NULL;
while ((long_u)(p - propInfo) < numItems && *p == '-')
{
+#if defined(FEAT_EVAL)
+ ch_log(NULL, "server_parse_message() item: %c, %s", p[-2], p);
+#endif
switch (p[1])
{
case 'r':
@@ -1326,7 +1339,8 @@
ga_concat(&reply, res);
else
{
- ga_concat(&reply, (char_u *)_(e_invalid_expression_received));
+ ga_concat(&reply,
+ (char_u *)_(e_invalid_expression_received));
ga_append(&reply, 0);
ga_concat(&reply, (char_u *)"-c 1");
}