Patch 9.0.0414 (after 9.0.0407) Problem: matchstr() still does not match column offset when done after a text search. Solution: Only use the line number for a multi-line search. Fix the test. (closes #10938) Files: src/regexp_bt.c, src/regexp_nfa.c, src/testdir/test_regexp_latin.vim
*** ../vim-9.0.0413/src/regexp_bt.c 2022-09-07 18:21:21.200339788 +0100 --- src/regexp_bt.c 2022-09-08 12:11:02.110577579 +0100 *************** *** 3441,3451 **** case RE_VCOL: { win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win; ! linenr_T lnum = rex.reg_firstlnum + rex.lnum; ! long_u vcol = 0; ! if (lnum >= 0 && lnum <= wp->w_buffer->b_ml.ml_line_count) ! vcol = (long_u)win_linetabsize(wp, lnum, rex.line, (colnr_T)(rex.input - rex.line)); if (!re_num_cmp(vcol + 1, scan)) status = RA_NOMATCH; --- 3441,3453 ---- case RE_VCOL: { win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win; ! linenr_T lnum = REG_MULTI ? rex.reg_firstlnum + rex.lnum : 1; ! long_u vcol; ! if (REG_MULTI && (lnum <= 0 ! || lnum > wp->w_buffer->b_ml.ml_line_count)) ! lnum = 1; ! vcol = (long_u)win_linetabsize(wp, lnum, rex.line, (colnr_T)(rex.input - rex.line)); if (!re_num_cmp(vcol + 1, scan)) status = RA_NOMATCH; *** ../vim-9.0.0413/src/regexp_nfa.c 2022-09-07 18:21:21.200339788 +0100 --- src/regexp_nfa.c 2022-09-08 12:06:46.790561260 +0100 *************** *** 6775,6786 **** } if (!result) { ! linenr_T lnum = rex.reg_firstlnum + rex.lnum; ! long_u vcol = 0; ! if (lnum >= 0 ! && lnum <= wp->w_buffer->b_ml.ml_line_count) ! vcol = (long_u)win_linetabsize(wp, lnum, rex.line, col); result = nfa_re_num_cmp(t->state->val, op, vcol + 1); } --- 6775,6788 ---- } if (!result) { ! linenr_T lnum = REG_MULTI ! ? rex.reg_firstlnum + rex.lnum : 1; ! long_u vcol; ! if (REG_MULTI && (lnum <= 0 ! || lnum > wp->w_buffer->b_ml.ml_line_count)) ! lnum = 1; ! vcol = (long_u)win_linetabsize(wp, lnum, rex.line, col); result = nfa_re_num_cmp(t->state->val, op, vcol + 1); } *** ../vim-9.0.0413/src/testdir/test_regexp_latin.vim 2022-09-07 18:21:21.200339788 +0100 --- src/testdir/test_regexp_latin.vim 2022-09-08 11:56:43.290518493 +0100 *************** *** 1145,1151 **** --- 1145,1157 ---- enddef def Test_compare_column_matchstr() + # do some search in text to set the line number, it should be ignored in + # matchstr(). enew + setline(1, ['one', 'two', 'three']) + :3 + :/ee + bwipe! set re=1 call assert_equal('aaa', matchstr('aaaaaaaaaaaaaaaaaaaa', '.*\%<5v')) set re=2 *** ../vim-9.0.0413/src/version.c 2022-09-08 10:55:34.233826402 +0100 --- src/version.c 2022-09-08 12:13:41.310501442 +0100 *************** *** 705,706 **** --- 705,708 ---- { /* Add new patch number below this line */ + /**/ + 414, /**/ -- How To Keep A Healthy Level Of Insanity: 12. Sing along at the opera. /// Bram Moolenaar -- b...@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 /// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/20220908112915.37B901C0B04%40moolenaar.net.