comparison src/sign.c @ 15402:c17b5e30a0af v8.1.0709

patch 8.1.0709: windows are updated for every added/deleted sign commit https://github.com/vim/vim/commit/27a472c32ed5b5298bca50864570a4a71ec1d204 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 9 21:47:30 2019 +0100 patch 8.1.0709: windows are updated for every added/deleted sign Problem: Windows are updated for every added/deleted sign. Solution: Do not call update_debug_sign(). Only redraw when the line with the sign is visible. (idea from neovim #9479)
author Bram Moolenaar <Bram@vim.org>
date Wed, 09 Jan 2019 22:00:05 +0100
parents 7444fffa482d
children 51b3c36b0523
comparison
equal deleted inserted replaced
15401:c1c2910907d8 15402:c17b5e30a0af
325 signlist_T *prev; // the previous sign 325 signlist_T *prev; // the previous sign
326 326
327 prev = NULL; 327 prev = NULL;
328 FOR_ALL_SIGNS_IN_BUF(buf, sign) 328 FOR_ALL_SIGNS_IN_BUF(buf, sign)
329 { 329 {
330 if (lnum == sign->lnum && id == sign->id && 330 if (lnum == sign->lnum && id == sign->id
331 sign_in_group(sign, groupname)) 331 && sign_in_group(sign, groupname))
332 { 332 {
333 // Update an existing sign 333 // Update an existing sign
334 sign->typenr = typenr; 334 sign->typenr = typenr;
335 return; 335 return;
336 } 336 }
425 lastp = &buf->b_signlist; 425 lastp = &buf->b_signlist;
426 lnum = 0; 426 lnum = 0;
427 for (sign = buf->b_signlist; sign != NULL; sign = next) 427 for (sign = buf->b_signlist; sign != NULL; sign = next)
428 { 428 {
429 next = sign->next; 429 next = sign->next;
430 if ((id == 0 || sign->id == id) && 430 if ((id == 0 || sign->id == id)
431 (atlnum == 0 || sign->lnum == atlnum) && 431 && (atlnum == 0 || sign->lnum == atlnum)
432 sign_in_group(sign, group)) 432 && sign_in_group(sign, group))
433 433
434 { 434 {
435 *lastp = next; 435 *lastp = next;
436 if (next != NULL) 436 if (next != NULL)
437 next->prev = sign->prev; 437 next->prev = sign->prev;
438 lnum = sign->lnum; 438 lnum = sign->lnum;
439 if (sign->group != NULL) 439 if (sign->group != NULL)
440 sign_group_unref(sign->group->sg_name); 440 sign_group_unref(sign->group->sg_name);
441 vim_free(sign); 441 vim_free(sign);
442 update_debug_sign(buf, lnum); 442 redraw_buf_line_later(buf, lnum);
443
443 // Check whether only one sign needs to be deleted 444 // Check whether only one sign needs to be deleted
444 // If deleting a sign with a specific identifer in a particular 445 // If deleting a sign with a specific identifer in a particular
445 // group or deleting any sign at a particular line number, delete 446 // group or deleting any sign at a particular line number, delete
446 // only one sign. 447 // only one sign.
447 if (group == NULL 448 if (group == NULL
451 } 452 }
452 else 453 else
453 lastp = &sign->next; 454 lastp = &sign->next;
454 } 455 }
455 456
456 // When deleted the last sign need to redraw the windows to remove the 457 // When deleting the last sign the cursor position may change, because the
457 // sign column. 458 // sign columns no longer shows.
458 if (buf->b_signlist == NULL) 459 if (buf->b_signlist == NULL)
459 {
460 redraw_buf_later(buf, NOT_VALID);
461 changed_cline_bef_curs(); 460 changed_cline_bef_curs();
462 }
463 461
464 return lnum; 462 return lnum;
465 } 463 }
466 464
467 465
930 buf_addsign(buf, *sign_id, sign_group, prio, lnum, sp->sn_typenr); 928 buf_addsign(buf, *sign_id, sign_group, prio, lnum, sp->sn_typenr);
931 else 929 else
932 // ":sign place {id} file={fname}": change sign type 930 // ":sign place {id} file={fname}": change sign type
933 lnum = buf_change_sign_type(buf, *sign_id, sign_group, sp->sn_typenr); 931 lnum = buf_change_sign_type(buf, *sign_id, sign_group, sp->sn_typenr);
934 if (lnum > 0) 932 if (lnum > 0)
935 update_debug_sign(buf, lnum); 933 redraw_buf_line_later(buf, lnum);
936 else 934 else
937 { 935 {
938 EMSG2(_("E885: Not possible to change sign %s"), sign_name); 936 EMSG2(_("E885: Not possible to change sign %s"), sign_name);
939 return FAIL; 937 return FAIL;
940 } 938 }
1066 // :sign place group={group} buffer={nr} 1064 // :sign place group={group} buffer={nr}
1067 // :sign place group=* buffer={nr} 1065 // :sign place group=* buffer={nr}
1068 // :sign place 1066 // :sign place
1069 // :sign place group={group} 1067 // :sign place group={group}
1070 // :sign place group=* 1068 // :sign place group=*
1071 if (lnum >= 0 || sign_name != NULL || 1069 if (lnum >= 0 || sign_name != NULL
1072 (group != NULL && *group == '\0')) 1070 || (group != NULL && *group == '\0'))
1073 EMSG(_(e_invarg)); 1071 EMSG(_(e_invarg));
1074 else 1072 else
1075 sign_list_placed(buf, group); 1073 sign_list_placed(buf, group);
1076 } 1074 }
1077 else 1075 else
1078 { 1076 {
1079 // Place a new sign 1077 // Place a new sign
1080 if (sign_name == NULL || buf == NULL || 1078 if (sign_name == NULL || buf == NULL
1081 (group != NULL && *group == '\0')) 1079 || (group != NULL && *group == '\0'))
1082 { 1080 {
1083 EMSG(_(e_invarg)); 1081 EMSG(_(e_invarg));
1084 return; 1082 return;
1085 } 1083 }
1086 1084
1172 { 1170 {
1173 EMSG(_(e_argreq)); 1171 EMSG(_(e_argreq));
1174 return; 1172 return;
1175 } 1173 }
1176 1174
1177 if (buf == NULL || (group != NULL && *group == '\0') || 1175 if (buf == NULL || (group != NULL && *group == '\0')
1178 lnum >= 0 || sign_name != NULL) 1176 || lnum >= 0 || sign_name != NULL)
1179 { 1177 {
1180 // File or buffer is not specified or an empty group is used 1178 // File or buffer is not specified or an empty group is used
1181 // or a line number or a sign name is specified. 1179 // or a line number or a sign name is specified.
1182 EMSG(_(e_invarg)); 1180 EMSG(_(e_invarg));
1183 return; 1181 return;
1328 } 1326 }
1329 1327
1330 // If the filename is not supplied for the sign place or the sign jump 1328 // If the filename is not supplied for the sign place or the sign jump
1331 // command, then use the current buffer. 1329 // command, then use the current buffer.
1332 if (filename == NULL && ((cmd == SIGNCMD_PLACE && lnum_arg) 1330 if (filename == NULL && ((cmd == SIGNCMD_PLACE && lnum_arg)
1333 || cmd == SIGNCMD_JUMP)) 1331 || cmd == SIGNCMD_JUMP))
1334 *buf = curwin->w_buffer; 1332 *buf = curwin->w_buffer;
1335 1333
1336 return OK; 1334 return OK;
1337 } 1335 }
1338 1336
1520 1518
1521 FOR_ALL_SIGNS_IN_BUF(buf, sign) 1519 FOR_ALL_SIGNS_IN_BUF(buf, sign)
1522 { 1520 {
1523 if (!sign_in_group(sign, sign_group)) 1521 if (!sign_in_group(sign, sign_group))
1524 continue; 1522 continue;
1525 if ((lnum == 0 && sign_id == 0) || 1523 if ((lnum == 0 && sign_id == 0)
1526 (sign_id == 0 && lnum == sign->lnum) || 1524 || (sign_id == 0 && lnum == sign->lnum)
1527 (lnum == 0 && sign_id == sign->id) || 1525 || (lnum == 0 && sign_id == sign->id)
1528 (lnum == sign->lnum && sign_id == sign->id)) 1526 || (lnum == sign->lnum && sign_id == sign->id))
1529 { 1527 {
1530 if ((sdict = sign_get_info(sign)) != NULL) 1528 if ((sdict = sign_get_info(sign)) != NULL)
1531 list_append_dict(l, sdict); 1529 list_append_dict(l, sdict);
1532 } 1530 }
1533 } 1531 }
1862 /* Expand last argument value (after equal sign). */ 1860 /* Expand last argument value (after equal sign). */
1863 xp->xp_pattern = p + 1; 1861 xp->xp_pattern = p + 1;
1864 switch (cmd_idx) 1862 switch (cmd_idx)
1865 { 1863 {
1866 case SIGNCMD_DEFINE: 1864 case SIGNCMD_DEFINE:
1867 if (STRNCMP(last, "texthl", p - last) == 0 || 1865 if (STRNCMP(last, "texthl", p - last) == 0
1868 STRNCMP(last, "linehl", p - last) == 0) 1866 || STRNCMP(last, "linehl", p - last) == 0)
1869 xp->xp_context = EXPAND_HIGHLIGHT; 1867 xp->xp_context = EXPAND_HIGHLIGHT;
1870 else if (STRNCMP(last, "icon", p - last) == 0) 1868 else if (STRNCMP(last, "icon", p - last) == 0)
1871 xp->xp_context = EXPAND_FILES; 1869 xp->xp_context = EXPAND_FILES;
1872 else 1870 else
1873 xp->xp_context = EXPAND_NOTHING; 1871 xp->xp_context = EXPAND_NOTHING;