mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
updated for version 7.4.313
Problem: Changing the return value of getpos() causes an error. (Jie Zhu) Solution: Revert getpos() and add getcurpos().
This commit is contained in:
@@ -1808,10 +1808,11 @@ getcharmod( ) Number modifiers for the last typed character
|
|||||||
getcmdline() String return the current command-line
|
getcmdline() String return the current command-line
|
||||||
getcmdpos() Number return cursor position in command-line
|
getcmdpos() Number return cursor position in command-line
|
||||||
getcmdtype() String return the current command-line type
|
getcmdtype() String return the current command-line type
|
||||||
|
getcurpos() List position of the cursor
|
||||||
getcwd() String the current working directory
|
getcwd() String the current working directory
|
||||||
|
getfontname( [{name}]) String name of font being used
|
||||||
getfperm( {fname}) String file permissions of file {fname}
|
getfperm( {fname}) String file permissions of file {fname}
|
||||||
getfsize( {fname}) Number size in bytes of file {fname}
|
getfsize( {fname}) Number size in bytes of file {fname}
|
||||||
getfontname( [{name}]) String name of font being used
|
|
||||||
getftime( {fname}) Number last modification time of file
|
getftime( {fname}) Number last modification time of file
|
||||||
getftype( {fname}) String description of type of file {fname}
|
getftype( {fname}) String description of type of file {fname}
|
||||||
getline( {lnum}) String line {lnum} of current buffer
|
getline( {lnum}) String line {lnum} of current buffer
|
||||||
@@ -2606,8 +2607,8 @@ cursor({list})
|
|||||||
with two, three or four item:
|
with two, three or four item:
|
||||||
[{lnum}, {col}, {off}]
|
[{lnum}, {col}, {off}]
|
||||||
[{lnum}, {col}, {off}, {curswant}]
|
[{lnum}, {col}, {off}, {curswant}]
|
||||||
This is like the return value of |getpos()|, but without the
|
This is like the return value of |getpos()| or |getcurpos|,
|
||||||
first item.
|
but without the first item.
|
||||||
|
|
||||||
Does not change the jumplist.
|
Does not change the jumplist.
|
||||||
If {lnum} is greater than the number of lines in the buffer,
|
If {lnum} is greater than the number of lines in the buffer,
|
||||||
@@ -2617,6 +2618,8 @@ cursor({list})
|
|||||||
the cursor will be positioned at the last character in the
|
the cursor will be positioned at the last character in the
|
||||||
line.
|
line.
|
||||||
If {col} is zero, the cursor will stay in the current column.
|
If {col} is zero, the cursor will stay in the current column.
|
||||||
|
If {curswant} is given it is used to set the preferred column
|
||||||
|
for vertical movment. Otherwise {col} is used.
|
||||||
When 'virtualedit' is used {off} specifies the offset in
|
When 'virtualedit' is used {off} specifies the offset in
|
||||||
screen columns from the start of the character. E.g., a
|
screen columns from the start of the character. E.g., a
|
||||||
position within a <Tab> or after the last character.
|
position within a <Tab> or after the last character.
|
||||||
@@ -3340,6 +3343,17 @@ getcmdtype() *getcmdtype()*
|
|||||||
Returns an empty string otherwise.
|
Returns an empty string otherwise.
|
||||||
Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
|
Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
|
||||||
|
|
||||||
|
*getcurpos()*
|
||||||
|
getcurpos() Get the position of the cursor. This is like getpos('.'), but
|
||||||
|
includes an extra item in the list:
|
||||||
|
[bufnum, lnum, col, off, curswant]
|
||||||
|
The "curswant" number is the preferred column when moving the
|
||||||
|
cursor vertically.
|
||||||
|
This can be used to save and restore the cursor position: >
|
||||||
|
let save_cursor = getcurpos()
|
||||||
|
MoveTheCursorAround
|
||||||
|
call setpos('.', save_cursor)
|
||||||
|
|
||||||
*getcwd()*
|
*getcwd()*
|
||||||
getcwd() The result is a String, which is the name of the current
|
getcwd() The result is a String, which is the name of the current
|
||||||
working directory.
|
working directory.
|
||||||
@@ -4499,10 +4513,10 @@ getpid() Return a Number which is the process ID of the Vim process.
|
|||||||
|
|
||||||
*getpos()*
|
*getpos()*
|
||||||
getpos({expr}) Get the position for {expr}. For possible values of {expr}
|
getpos({expr}) Get the position for {expr}. For possible values of {expr}
|
||||||
see |line()|.
|
see |line()|. For getting the cursor position see
|
||||||
The result is a |List| with four or five numbers:
|
|getcurpos()|.
|
||||||
|
The result is a |List| with four numbers:
|
||||||
[bufnum, lnum, col, off]
|
[bufnum, lnum, col, off]
|
||||||
[bufnum, lnum, col, off, curswant]
|
|
||||||
"bufnum" is zero, unless a mark like '0 or 'A is used, then it
|
"bufnum" is zero, unless a mark like '0 or 'A is used, then it
|
||||||
is the buffer number of the mark.
|
is the buffer number of the mark.
|
||||||
"lnum" and "col" are the position in the buffer. The first
|
"lnum" and "col" are the position in the buffer. The first
|
||||||
@@ -4511,16 +4525,14 @@ getpos({expr}) Get the position for {expr}. For possible values of {expr}
|
|||||||
it is the offset in screen columns from the start of the
|
it is the offset in screen columns from the start of the
|
||||||
character. E.g., a position within a <Tab> or after the last
|
character. E.g., a position within a <Tab> or after the last
|
||||||
character.
|
character.
|
||||||
The "curswant" number is only added for getpos('.'), it is the
|
|
||||||
preferred column when moving the cursor vertically.
|
|
||||||
Note that for '< and '> Visual mode matters: when it is "V"
|
Note that for '< and '> Visual mode matters: when it is "V"
|
||||||
(visual line mode) the column of '< is zero and the column of
|
(visual line mode) the column of '< is zero and the column of
|
||||||
'> is a large number.
|
'> is a large number.
|
||||||
This can be used to save and restore the cursor position: >
|
This can be used to save and restore the position of a mark: >
|
||||||
let save_cursor = getpos(".")
|
let save_a_mark = getpos("'a")
|
||||||
MoveTheCursorAround
|
...
|
||||||
call setpos('.', save_cursor)
|
call setpos(''a', save_a_mark
|
||||||
< Also see |setpos()|.
|
< Also see |getcurpos()| and |setpos()|.
|
||||||
|
|
||||||
or({expr}, {expr}) *or()*
|
or({expr}, {expr}) *or()*
|
||||||
Bitwise OR on the two arguments. The arguments are converted
|
Bitwise OR on the two arguments. The arguments are converted
|
||||||
@@ -5353,7 +5365,7 @@ setpos({expr}, {list})
|
|||||||
Returns 0 when the position could be set, -1 otherwise.
|
Returns 0 when the position could be set, -1 otherwise.
|
||||||
An error message is given if {expr} is invalid.
|
An error message is given if {expr} is invalid.
|
||||||
|
|
||||||
Also see |getpos()|
|
Also see |getpos()| and |getcurpos()|.
|
||||||
|
|
||||||
This does not restore the preferred column for moving
|
This does not restore the preferred column for moving
|
||||||
vertically; if you set the cursor position with this, |j| and
|
vertically; if you set the cursor position with this, |j| and
|
||||||
|
31
src/eval.c
31
src/eval.c
@@ -560,6 +560,7 @@ static void f_getftype __ARGS((typval_T *argvars, typval_T *rettv));
|
|||||||
static void f_getline __ARGS((typval_T *argvars, typval_T *rettv));
|
static void f_getline __ARGS((typval_T *argvars, typval_T *rettv));
|
||||||
static void f_getmatches __ARGS((typval_T *argvars, typval_T *rettv));
|
static void f_getmatches __ARGS((typval_T *argvars, typval_T *rettv));
|
||||||
static void f_getpid __ARGS((typval_T *argvars, typval_T *rettv));
|
static void f_getpid __ARGS((typval_T *argvars, typval_T *rettv));
|
||||||
|
static void f_getcurpos __ARGS((typval_T *argvars, typval_T *rettv));
|
||||||
static void f_getpos __ARGS((typval_T *argvars, typval_T *rettv));
|
static void f_getpos __ARGS((typval_T *argvars, typval_T *rettv));
|
||||||
static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv));
|
static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv));
|
||||||
static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv));
|
static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv));
|
||||||
@@ -7967,6 +7968,7 @@ static struct fst
|
|||||||
{"getcmdline", 0, 0, f_getcmdline},
|
{"getcmdline", 0, 0, f_getcmdline},
|
||||||
{"getcmdpos", 0, 0, f_getcmdpos},
|
{"getcmdpos", 0, 0, f_getcmdpos},
|
||||||
{"getcmdtype", 0, 0, f_getcmdtype},
|
{"getcmdtype", 0, 0, f_getcmdtype},
|
||||||
|
{"getcurpos", 0, 0, f_getcurpos},
|
||||||
{"getcwd", 0, 0, f_getcwd},
|
{"getcwd", 0, 0, f_getcwd},
|
||||||
{"getfontname", 0, 1, f_getfontname},
|
{"getfontname", 0, 1, f_getfontname},
|
||||||
{"getfperm", 1, 1, f_getfperm},
|
{"getfperm", 1, 1, f_getfperm},
|
||||||
@@ -11780,6 +11782,19 @@ f_getpid(argvars, rettv)
|
|||||||
rettv->vval.v_number = mch_get_pid();
|
rettv->vval.v_number = mch_get_pid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void getpos_both __ARGS((typval_T *argvars, typval_T *rettv, int getcurpos));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "getcurpos()" function
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
f_getcurpos(argvars, rettv)
|
||||||
|
typval_T *argvars;
|
||||||
|
typval_T *rettv;
|
||||||
|
{
|
||||||
|
getpos_both(argvars, rettv, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "getpos(string)" function
|
* "getpos(string)" function
|
||||||
*/
|
*/
|
||||||
@@ -11787,6 +11802,15 @@ f_getpid(argvars, rettv)
|
|||||||
f_getpos(argvars, rettv)
|
f_getpos(argvars, rettv)
|
||||||
typval_T *argvars;
|
typval_T *argvars;
|
||||||
typval_T *rettv;
|
typval_T *rettv;
|
||||||
|
{
|
||||||
|
getpos_both(argvars, rettv, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
getpos_both(argvars, rettv, getcurpos)
|
||||||
|
typval_T *argvars;
|
||||||
|
typval_T *rettv;
|
||||||
|
int getcurpos;
|
||||||
{
|
{
|
||||||
pos_T *fp;
|
pos_T *fp;
|
||||||
list_T *l;
|
list_T *l;
|
||||||
@@ -11795,7 +11819,10 @@ f_getpos(argvars, rettv)
|
|||||||
if (rettv_list_alloc(rettv) == OK)
|
if (rettv_list_alloc(rettv) == OK)
|
||||||
{
|
{
|
||||||
l = rettv->vval.v_list;
|
l = rettv->vval.v_list;
|
||||||
fp = var2fpos(&argvars[0], TRUE, &fnum);
|
if (getcurpos)
|
||||||
|
fp = &curwin->w_cursor;
|
||||||
|
else
|
||||||
|
fp = var2fpos(&argvars[0], TRUE, &fnum);
|
||||||
if (fnum != -1)
|
if (fnum != -1)
|
||||||
list_append_number(l, (varnumber_T)fnum);
|
list_append_number(l, (varnumber_T)fnum);
|
||||||
else
|
else
|
||||||
@@ -11810,7 +11837,7 @@ f_getpos(argvars, rettv)
|
|||||||
(fp != NULL) ? (varnumber_T)fp->coladd :
|
(fp != NULL) ? (varnumber_T)fp->coladd :
|
||||||
#endif
|
#endif
|
||||||
(varnumber_T)0);
|
(varnumber_T)0);
|
||||||
if (fp == &curwin->w_cursor)
|
if (getcurpos)
|
||||||
list_append_number(l, (varnumber_T)curwin->w_curswant + 1);
|
list_append_number(l, (varnumber_T)curwin->w_curswant + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -190,9 +190,9 @@ endfun
|
|||||||
:$put =v:exception
|
:$put =v:exception
|
||||||
:endtry
|
:endtry
|
||||||
:"
|
:"
|
||||||
:$put ='{{{1 setpos/getpos'
|
:$put ='{{{1 getcurpos/setpos'
|
||||||
/^012345678
|
/^012345678
|
||||||
6l:let sp = getpos('.')
|
6l:let sp = getcurpos()
|
||||||
0:call setpos('.', sp)
|
0:call setpos('.', sp)
|
||||||
jyl:$put
|
jyl:$put
|
||||||
:"
|
:"
|
||||||
|
Binary file not shown.
@@ -734,6 +734,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
313,
|
||||||
/**/
|
/**/
|
||||||
312,
|
312,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user