comparison src/eval.c @ 28419:6e501ecd1bb7 v8.2.4734

patch 8.2.4734: getcharpos() may change a mark position Commit: https://github.com/vim/vim/commit/3caf1cce2b85a8f24195d057f0ad63082543e99e Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 11 13:05:16 2022 +0100 patch 8.2.4734: getcharpos() may change a mark position Problem: getcharpos() may change a mark position. Solution: Copy the mark position. (closes https://github.com/vim/vim/issues/10148)
author Bram Moolenaar <Bram@vim.org>
date Mon, 11 Apr 2022 14:15:04 +0200
parents b418e073b42f
children 4dcccb2673fe
comparison
equal deleted inserted replaced
28418:2da2c67d0db0 28419:6e501ecd1bb7
5634 return NULL; 5634 return NULL;
5635 5635
5636 name = tv_get_string_chk(varp); 5636 name = tv_get_string_chk(varp);
5637 if (name == NULL) 5637 if (name == NULL)
5638 return NULL; 5638 return NULL;
5639
5640 pos.lnum = 0;
5639 if (name[0] == '.' && (!in_vim9script() || name[1] == NUL)) 5641 if (name[0] == '.' && (!in_vim9script() || name[1] == NUL))
5640 { 5642 {
5641 // cursor 5643 // cursor
5642 pos = curwin->w_cursor; 5644 pos = curwin->w_cursor;
5643 if (charcol) 5645 }
5644 pos.col = buf_byteidx_to_charidx(curbuf, pos.lnum, pos.col); 5646 else if (name[0] == 'v' && name[1] == NUL)
5645 return &pos; 5647 {
5646 } 5648 // Visual start
5647 if (name[0] == 'v' && name[1] == NUL) // Visual start
5648 {
5649 if (VIsual_active) 5649 if (VIsual_active)
5650 pos = VIsual; 5650 pos = VIsual;
5651 else 5651 else
5652 pos = curwin->w_cursor; 5652 pos = curwin->w_cursor;
5653 if (charcol) 5653 }
5654 pos.col = buf_byteidx_to_charidx(curbuf, pos.lnum, pos.col); 5654 else if (name[0] == '\'' && (!in_vim9script()
5655 return &pos;
5656 }
5657 if (name[0] == '\'' && (!in_vim9script()
5658 || (name[1] != NUL && name[2] == NUL))) 5655 || (name[1] != NUL && name[2] == NUL)))
5659 { 5656 {
5660 // mark 5657 // mark
5661 pp = getmark_buf_fnum(curbuf, name[1], FALSE, fnum); 5658 pp = getmark_buf_fnum(curbuf, name[1], FALSE, fnum);
5662 if (pp == NULL || pp == (pos_T *)-1 || pp->lnum <= 0) 5659 if (pp == NULL || pp == (pos_T *)-1 || pp->lnum <= 0)
5663 return NULL; 5660 return NULL;
5661 pos = *pp;
5662 }
5663 if (pos.lnum != 0)
5664 {
5664 if (charcol) 5665 if (charcol)
5665 pp->col = buf_byteidx_to_charidx(curbuf, pp->lnum, pp->col); 5666 pos.col = buf_byteidx_to_charidx(curbuf, pos.lnum, pos.col);
5666 return pp; 5667 return &pos;
5667 } 5668 }
5668 5669
5669 pos.coladd = 0; 5670 pos.coladd = 0;
5670 5671
5671 if (name[0] == 'w' && dollar_lnum) 5672 if (name[0] == 'w' && dollar_lnum)