comparison src/mark.c @ 10730:44e9340dc604 v8.0.0255

patch 8.0.0255: setpos() does not use the buffer argument for all marks commit https://github.com/vim/vim/commit/f13e00b2cf381e13fd327b5387a5bd6f004ac2a3 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 28 18:23:54 2017 +0100 patch 8.0.0255: setpos() does not use the buffer argument for all marks Problem: When calling setpos() with a buffer argument it often is ignored. (Matthew Malcomson) Solution: Make the buffer argument work for all marks local to a buffer. (neovim #5713) Add more tests.
author Christian Brabandt <cb@256bit.org>
date Sat, 28 Jan 2017 18:30:04 +0100
parents cd16ef948ad1
children 778c10516955
comparison
equal deleted inserted replaced
10729:4441ce7a58f2 10730:44e9340dc604
55 */ 55 */
56 int 56 int
57 setmark_pos(int c, pos_T *pos, int fnum) 57 setmark_pos(int c, pos_T *pos, int fnum)
58 { 58 {
59 int i; 59 int i;
60 buf_T *buf;
60 61
61 /* Check for a special key (may cause islower() to crash). */ 62 /* Check for a special key (may cause islower() to crash). */
62 if (c < 0) 63 if (c < 0)
63 return FAIL; 64 return FAIL;
64 65
73 else 74 else
74 curwin->w_pcmark = *pos; 75 curwin->w_pcmark = *pos;
75 return OK; 76 return OK;
76 } 77 }
77 78
79 buf = buflist_findnr(fnum);
80 if (buf == NULL)
81 return FAIL;
82
78 if (c == '"') 83 if (c == '"')
79 { 84 {
80 curbuf->b_last_cursor = *pos; 85 buf->b_last_cursor = *pos;
81 return OK; 86 return OK;
82 } 87 }
83 88
84 /* Allow setting '[ and '] for an autocommand that simulates reading a 89 /* Allow setting '[ and '] for an autocommand that simulates reading a
85 * file. */ 90 * file. */
86 if (c == '[') 91 if (c == '[')
87 { 92 {
88 curbuf->b_op_start = *pos; 93 buf->b_op_start = *pos;
89 return OK; 94 return OK;
90 } 95 }
91 if (c == ']') 96 if (c == ']')
92 { 97 {
93 curbuf->b_op_end = *pos; 98 buf->b_op_end = *pos;
94 return OK; 99 return OK;
95 } 100 }
96 101
97 if (c == '<' || c == '>') 102 if (c == '<' || c == '>')
98 { 103 {
99 if (c == '<') 104 if (c == '<')
100 curbuf->b_visual.vi_start = *pos; 105 buf->b_visual.vi_start = *pos;
101 else 106 else
102 curbuf->b_visual.vi_end = *pos; 107 buf->b_visual.vi_end = *pos;
103 if (curbuf->b_visual.vi_mode == NUL) 108 if (buf->b_visual.vi_mode == NUL)
104 /* Visual_mode has not yet been set, use a sane default. */ 109 /* Visual_mode has not yet been set, use a sane default. */
105 curbuf->b_visual.vi_mode = 'v'; 110 buf->b_visual.vi_mode = 'v';
106 return OK; 111 return OK;
107 } 112 }
108 113
109 if (ASCII_ISLOWER(c)) 114 if (ASCII_ISLOWER(c))
110 { 115 {
111 i = c - 'a'; 116 i = c - 'a';
112 curbuf->b_namedm[i] = *pos; 117 buf->b_namedm[i] = *pos;
113 return OK; 118 return OK;
114 } 119 }
115 if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c)) 120 if (ASCII_ISUPPER(c) || VIM_ISDIGIT(c))
116 { 121 {
117 if (VIM_ISDIGIT(c)) 122 if (VIM_ISDIGIT(c))
394 } 399 }
395 else if (c == '<' || c == '>') /* start/end of visual area */ 400 else if (c == '<' || c == '>') /* start/end of visual area */
396 { 401 {
397 startp = &buf->b_visual.vi_start; 402 startp = &buf->b_visual.vi_start;
398 endp = &buf->b_visual.vi_end; 403 endp = &buf->b_visual.vi_end;
399 if ((c == '<') == lt(*startp, *endp)) 404 if (((c == '<') == lt(*startp, *endp) || endp->lnum == 0)
405 && startp->lnum != 0)
400 posp = startp; 406 posp = startp;
401 else 407 else
402 posp = endp; 408 posp = endp;
403 /* 409 /*
404 * For Visual line mode, set mark at begin or end of line 410 * For Visual line mode, set mark at begin or end of line