To: vim_dev@googlegroups.com Subject: Patch 8.2.3747 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3747 (after 8.2.3743) Problem: Cannot remove highlight from an existing sign. (James McCoy) Solution: Only reject empty argument for a new sign. Files: src/sign.c, src/testdir/test_signs.vim *** ../vim-8.2.3746/src/sign.c 2021-12-05 13:02:47.028928408 +0000 --- src/sign.c 2021-12-05 17:36:14.549312453 +0000 *************** *** 1078,1090 **** return FAIL; if (linehl != NULL) ! sp->sn_line_hl = syn_check_group(linehl, (int)STRLEN(linehl)); if (texthl != NULL) ! sp->sn_text_hl = syn_check_group(texthl, (int)STRLEN(texthl)); if (culhl != NULL) ! sp->sn_cul_hl = syn_check_group(culhl, (int)STRLEN(culhl)); return OK; } --- 1078,1105 ---- return FAIL; if (linehl != NULL) ! { ! if (*linehl == NUL) ! sp->sn_line_hl = 0; ! else ! sp->sn_line_hl = syn_check_group(linehl, (int)STRLEN(linehl)); ! } if (texthl != NULL) ! { ! if (*texthl == NUL) ! sp->sn_text_hl = 0; ! else ! sp->sn_text_hl = syn_check_group(texthl, (int)STRLEN(texthl)); ! } if (culhl != NULL) ! { ! if (*culhl == NUL) ! sp->sn_cul_hl = 0; ! else ! sp->sn_cul_hl = syn_check_group(culhl, (int)STRLEN(culhl)); ! } return OK; } *************** *** 1319,1325 **** char_u *linehl = NULL; char_u *texthl = NULL; char_u *culhl = NULL; ! int failed = FALSE; // set values for a defined sign. for (;;) --- 1334,1344 ---- char_u *linehl = NULL; char_u *texthl = NULL; char_u *culhl = NULL; ! int failed = FALSE; ! sign_T *sp_prev; ! int exists; ! ! exists = sign_find(sign_name, &sp_prev) != NULL; // set values for a defined sign. for (;;) *************** *** 1341,1347 **** else if (STRNCMP(arg, "linehl=", 7) == 0) { arg += 7; ! if (check_empty_group(p - arg, "linehl") == FAIL) { failed = TRUE; break; --- 1360,1366 ---- else if (STRNCMP(arg, "linehl=", 7) == 0) { arg += 7; ! if (!exists && check_empty_group(p - arg, "linehl") == FAIL) { failed = TRUE; break; *************** *** 1351,1357 **** else if (STRNCMP(arg, "texthl=", 7) == 0) { arg += 7; ! if (check_empty_group(p - arg, "texthl") == FAIL) { failed = TRUE; break; --- 1370,1376 ---- else if (STRNCMP(arg, "texthl=", 7) == 0) { arg += 7; ! if (!exists && check_empty_group(p - arg, "texthl") == FAIL) { failed = TRUE; break; *************** *** 1361,1367 **** else if (STRNCMP(arg, "culhl=", 6) == 0) { arg += 6; ! if (check_empty_group(p - arg, "culhl") == FAIL) { failed = TRUE; break; --- 1380,1386 ---- else if (STRNCMP(arg, "culhl=", 6) == 0) { arg += 6; ! if (!exists && check_empty_group(p - arg, "culhl") == FAIL) { failed = TRUE; break; *** ../vim-8.2.3746/src/testdir/test_signs.vim 2021-12-05 13:02:47.028928408 +0000 --- src/testdir/test_signs.vim 2021-12-05 17:44:04.663016871 +0000 *************** *** 126,134 **** call assert_fails("sign define Sign4 text= linehl=Comment", 'E239:') call assert_fails("sign define Sign4 text=\\ ab linehl=Comment", 'E239:') ! call assert_fails("sign define Sign4 linehl=", 'E1249: Group name missing for linehl') ! call assert_fails("sign define Sign4 culhl=", 'E1249: Group name missing for culhl') ! call assert_fails("sign define Sign4 texthl=", 'E1249: Group name missing for texthl') " define sign with whitespace sign define Sign4 text=\ X linehl=Comment --- 126,159 ---- call assert_fails("sign define Sign4 text= linehl=Comment", 'E239:') call assert_fails("sign define Sign4 text=\\ ab linehl=Comment", 'E239:') ! " an empty highlight argument for a new sign is an error ! call assert_fails("sign define SignX linehl=", 'E1249: Group name missing for linehl') ! call assert_fails("sign define SignX culhl=", 'E1249: Group name missing for culhl') ! call assert_fails("sign define SignX texthl=", 'E1249: Group name missing for texthl') ! ! " an empty highlight argument for an existing sign clears it ! sign define SignY texthl=TextHl culhl=CulHl linehl=LineHl ! let sl = sign_getdefined('SignY')[0] ! call assert_equal('TextHl', sl.texthl) ! call assert_equal('CulHl', sl.culhl) ! call assert_equal('LineHl', sl.linehl) ! ! sign define SignY texthl= culhl=CulHl linehl=LineHl ! let sl = sign_getdefined('SignY')[0] ! call assert_false(has_key(sl, 'texthl')) ! call assert_equal('CulHl', sl.culhl) ! call assert_equal('LineHl', sl.linehl) ! ! sign define SignY linehl= ! let sl = sign_getdefined('SignY')[0] ! call assert_false(has_key(sl, 'linehl')) ! call assert_equal('CulHl', sl.culhl) ! ! sign define SignY culhl= ! let sl = sign_getdefined('SignY')[0] ! call assert_false(has_key(sl, 'culhl')) ! ! sign undefine SignY " define sign with whitespace sign define Sign4 text=\ X linehl=Comment *** ../vim-8.2.3746/src/version.c 2021-12-05 17:20:20.426818196 +0000 --- src/version.c 2021-12-05 17:44:38.459075482 +0000 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 3747, /**/ -- For society, it's probably a good thing that engineers value function over appearance. For example, you wouldn't want engineers to build nuclear power plants that only _look_ like they would keep all the radiation inside. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///