comparison src/if_xcmdsrv.c @ 31287:fa309d9af73c v9.0.0977

patch 9.0.0977: it is not easy to see what client-server commands are doing Commit: https://github.com/vim/vim/commit/4c5678ff0c376661d4a8183a5a074a1203413b9d Author: Bram Moolenaar <Bram@vim.org> Date: Wed Nov 30 18:12:19 2022 +0000 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.
author Bram Moolenaar <Bram@vim.org>
date Wed, 30 Nov 2022 19:15:10 +0100
parents 58fb880f3607
children 27c9212d10aa
comparison
equal deleted inserted replaced
31286:33c4af586833 31287:fa309d9af73c
386 if (result != NULL) 386 if (result != NULL)
387 *result = NULL; 387 *result = NULL;
388 if (name == NULL || *name == NUL) 388 if (name == NULL || *name == NUL)
389 name = (char_u *)"GVIM"; // use a default name 389 name = (char_u *)"GVIM"; // use a default name
390 390
391 if (commProperty == None && dpy != NULL) 391 if (commProperty == None && dpy != NULL && SendInit(dpy) < 0)
392 { 392 return -1;
393 if (SendInit(dpy) < 0) 393
394 return -1; 394 #if defined(FEAT_EVAL)
395 } 395 ch_log(NULL, "serverSendToVim(%s, %s)", name, cmd);
396 #endif
396 397
397 // Execute locally if no display or target is ourselves 398 // Execute locally if no display or target is ourselves
398 if (dpy == NULL || (serverName != NULL && STRICMP(name, serverName) == 0)) 399 if (dpy == NULL || (serverName != NULL && STRICMP(name, serverName) == 0))
399 return sendToLocalVim(cmd, asExpr, result); 400 return sendToLocalVim(cmd, asExpr, result);
400 401
492 { 493 {
493 pcPtr->nextPtr = pending.nextPtr; 494 pcPtr->nextPtr = pending.nextPtr;
494 break; 495 break;
495 } 496 }
496 } 497 }
498
499 #if defined(FEAT_EVAL)
500 ch_log(NULL, "serverSendToVim() result: %s",
501 pending.result == NULL ? "NULL" : (char *)pending.result);
502 #endif
497 if (result != NULL) 503 if (result != NULL)
498 *result = pending.result; 504 *result = pending.result;
499 else 505 else
500 vim_free(pending.result); 506 vim_free(pending.result);
501 507
1219 { 1225 {
1220 char_u *p; 1226 char_u *p;
1221 int code; 1227 int code;
1222 char_u *tofree; 1228 char_u *tofree;
1223 1229
1230 #if defined(FEAT_EVAL)
1231 ch_log(NULL, "server_parse_message() numItems: %ld", numItems);
1232 #endif
1233
1224 /* 1234 /*
1225 * Several commands and results could arrive in the property at 1235 * Several commands and results could arrive in the property at
1226 * one time; each iteration through the outer loop handles a 1236 * one time; each iteration through the outer loop handles a
1227 * single command or result. 1237 * single command or result.
1228 */ 1238 */
1238 { 1248 {
1239 p++; 1249 p++;
1240 continue; 1250 continue;
1241 } 1251 }
1242 1252
1243 if ((*p == 'c' || *p == 'k') && (p[1] == 0)) 1253 if ((*p == 'c' || *p == 'k') && p[1] == 0)
1244 { 1254 {
1245 Window resWindow; 1255 Window resWindow;
1246 char_u *name, *script, *serial, *end; 1256 char_u *name, *script, *serial, *end;
1247 Bool asKeys = *p == 'k'; 1257 Bool asKeys = *p == 'k';
1248 char_u *enc; 1258 char_u *enc;
1259 serial = (char_u *)""; 1269 serial = (char_u *)"";
1260 script = NULL; 1270 script = NULL;
1261 enc = NULL; 1271 enc = NULL;
1262 while ((long_u)(p - propInfo) < numItems && *p == '-') 1272 while ((long_u)(p - propInfo) < numItems && *p == '-')
1263 { 1273 {
1274 #if defined(FEAT_EVAL)
1275 ch_log(NULL, "server_parse_message() item: %c, %s", p[-2], p);
1276 #endif
1264 switch (p[1]) 1277 switch (p[1])
1265 { 1278 {
1266 case 'r': 1279 case 'r':
1267 end = skipwhite(p + 2); 1280 end = skipwhite(p + 2);
1268 resWindow = 0; 1281 resWindow = 0;
1324 // Evaluate the expression and return the result. 1337 // Evaluate the expression and return the result.
1325 if (res != NULL) 1338 if (res != NULL)
1326 ga_concat(&reply, res); 1339 ga_concat(&reply, res);
1327 else 1340 else
1328 { 1341 {
1329 ga_concat(&reply, (char_u *)_(e_invalid_expression_received)); 1342 ga_concat(&reply,
1343 (char_u *)_(e_invalid_expression_received));
1330 ga_append(&reply, 0); 1344 ga_append(&reply, 0);
1331 ga_concat(&reply, (char_u *)"-c 1"); 1345 ga_concat(&reply, (char_u *)"-c 1");
1332 } 1346 }
1333 ga_append(&reply, NUL); 1347 ga_append(&reply, NUL);
1334 (void)AppendPropCarefully(dpy, resWindow, commProperty, 1348 (void)AppendPropCarefully(dpy, resWindow, commProperty,