mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.1727: a popup created with "cursorline" will ignore "firstline"
Problem: A popup created with "cursorline" will ignore "firstline".
Solution: When both "cursorline" and "firstline" are present put the cursor
on "firstline". (closes vim/vim#7000) Add the "winid" argument to
getcurpos().
99ca9c4868
Skip popup window related code.
Cherry-pick all of Test_getcurpos_setpos() from patch 8.2.0610.
This commit is contained in:
parent
92e92f02e7
commit
8ba9f19961
@ -178,7 +178,7 @@ getcmdtype() String return current command-line type
|
|||||||
getcmdwintype() String return current command-line window type
|
getcmdwintype() String return current command-line window type
|
||||||
getcompletion({pat}, {type} [, {filtered}])
|
getcompletion({pat}, {type} [, {filtered}])
|
||||||
List list of cmdline completion matches
|
List list of cmdline completion matches
|
||||||
getcurpos() List position of the cursor
|
getcurpos([{winnr}]) List position of the cursor
|
||||||
getcwd([{winnr} [, {tabnr}]]) String get the current working directory
|
getcwd([{winnr} [, {tabnr}]]) String get the current working directory
|
||||||
getenv({name}) String return environment variable
|
getenv({name}) String return environment variable
|
||||||
getfontname([{name}]) String name of font being used
|
getfontname([{name}]) String name of font being used
|
||||||
@ -2786,13 +2786,20 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
|
|||||||
GetPattern()->getcompletion('color')
|
GetPattern()->getcompletion('color')
|
||||||
<
|
<
|
||||||
*getcurpos()*
|
*getcurpos()*
|
||||||
getcurpos() Get the position of the cursor. This is like getpos('.'), but
|
getcurpos([{winid}])
|
||||||
|
Get the position of the cursor. This is like getpos('.'), but
|
||||||
includes an extra "curswant" in the list:
|
includes an extra "curswant" in the list:
|
||||||
[0, lnum, col, off, curswant] ~
|
[0, lnum, col, off, curswant] ~
|
||||||
The "curswant" number is the preferred column when moving the
|
The "curswant" number is the preferred column when moving the
|
||||||
cursor vertically. Also see |getpos()|.
|
cursor vertically. Also see |getpos()|.
|
||||||
The first "bufnum" item is always zero.
|
The first "bufnum" item is always zero.
|
||||||
|
|
||||||
|
The optional {winid} argument can specify the window. It can
|
||||||
|
be the window number or the |window-ID|. The last known
|
||||||
|
cursor position is returned, this may be invalid for the
|
||||||
|
current value of the buffer if it is not the current window.
|
||||||
|
If {winid} is invalid a list with zeroes is returned.
|
||||||
|
|
||||||
This can be used to save and restore the cursor position: >
|
This can be used to save and restore the cursor position: >
|
||||||
let save_cursor = getcurpos()
|
let save_cursor = getcurpos()
|
||||||
MoveTheCursorAround
|
MoveTheCursorAround
|
||||||
|
@ -151,7 +151,7 @@ return {
|
|||||||
getcmdtype={},
|
getcmdtype={},
|
||||||
getcmdwintype={},
|
getcmdwintype={},
|
||||||
getcompletion={args={2, 3}, base=1},
|
getcompletion={args={2, 3}, base=1},
|
||||||
getcurpos={},
|
getcurpos={args={0, 1}, base=1},
|
||||||
getcwd={args={0, 2}, base=1},
|
getcwd={args={0, 2}, base=1},
|
||||||
getenv={args=1, base=1},
|
getenv={args=1, base=1},
|
||||||
getfontname={args={0, 1}},
|
getfontname={args={0, 1}},
|
||||||
|
@ -3845,37 +3845,45 @@ static void f_getpid(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
|
|
||||||
static void getpos_both(typval_T *argvars, typval_T *rettv, bool getcurpos)
|
static void getpos_both(typval_T *argvars, typval_T *rettv, bool getcurpos)
|
||||||
{
|
{
|
||||||
pos_T *fp;
|
pos_T *fp = NULL;
|
||||||
|
win_T *wp = curwin;
|
||||||
int fnum = -1;
|
int fnum = -1;
|
||||||
|
|
||||||
if (getcurpos) {
|
if (getcurpos) {
|
||||||
fp = &curwin->w_cursor;
|
if (argvars[0].v_type != VAR_UNKNOWN) {
|
||||||
|
wp = find_win_by_nr_or_id(&argvars[0]);
|
||||||
|
if (wp != NULL) {
|
||||||
|
fp = &wp->w_cursor;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fp = &curwin->w_cursor;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fp = var2fpos(&argvars[0], true, &fnum);
|
fp = var2fpos(&argvars[0], true, &fnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
list_T *const l = tv_list_alloc_ret(rettv, 4 + (!!getcurpos));
|
list_T *const l = tv_list_alloc_ret(rettv, 4 + (!!getcurpos));
|
||||||
tv_list_append_number(l, (fnum != -1) ? (varnumber_T)fnum : (varnumber_T)0);
|
tv_list_append_number(l, (fnum != -1) ? (varnumber_T)fnum : (varnumber_T)0);
|
||||||
|
tv_list_append_number(l, ((fp != NULL) ? (varnumber_T)fp->lnum : (varnumber_T)0));
|
||||||
tv_list_append_number(l, ((fp != NULL)
|
tv_list_append_number(l, ((fp != NULL)
|
||||||
? (varnumber_T)fp->lnum
|
? (varnumber_T)(fp->col == MAXCOL ? MAXCOL : fp->col + 1)
|
||||||
: (varnumber_T)0));
|
: (varnumber_T)0));
|
||||||
tv_list_append_number(l, ((fp != NULL)
|
|
||||||
? (varnumber_T)(fp->col == MAXCOL ? MAXCOL : fp->col + 1)
|
|
||||||
: (varnumber_T)0));
|
|
||||||
tv_list_append_number(l, (fp != NULL) ? (varnumber_T)fp->coladd : (varnumber_T)0);
|
tv_list_append_number(l, (fp != NULL) ? (varnumber_T)fp->coladd : (varnumber_T)0);
|
||||||
if (getcurpos) {
|
if (getcurpos) {
|
||||||
const int save_set_curswant = curwin->w_set_curswant;
|
const int save_set_curswant = curwin->w_set_curswant;
|
||||||
const colnr_T save_curswant = curwin->w_curswant;
|
const colnr_T save_curswant = curwin->w_curswant;
|
||||||
const colnr_T save_virtcol = curwin->w_virtcol;
|
const colnr_T save_virtcol = curwin->w_virtcol;
|
||||||
|
|
||||||
update_curswant();
|
if (wp == curwin) {
|
||||||
tv_list_append_number(l, (curwin->w_curswant == MAXCOL
|
update_curswant();
|
||||||
? (varnumber_T)MAXCOL
|
}
|
||||||
: (varnumber_T)curwin->w_curswant + 1));
|
tv_list_append_number(l, (wp == NULL) ? 0 : (wp->w_curswant == MAXCOL)
|
||||||
|
? (varnumber_T)MAXCOL
|
||||||
|
: (varnumber_T)wp->w_curswant + 1);
|
||||||
|
|
||||||
// Do not change "curswant", as it is unexpected that a get
|
// Do not change "curswant", as it is unexpected that a get
|
||||||
// function has a side effect.
|
// function has a side effect.
|
||||||
if (save_set_curswant) {
|
if (wp == curwin && save_set_curswant) {
|
||||||
curwin->w_set_curswant = save_set_curswant;
|
curwin->w_set_curswant = save_set_curswant;
|
||||||
curwin->w_curswant = save_curswant;
|
curwin->w_curswant = save_curswant;
|
||||||
curwin->w_virtcol = save_virtcol;
|
curwin->w_virtcol = save_virtcol;
|
||||||
|
@ -1712,6 +1712,33 @@ func Test_nr2char()
|
|||||||
call assert_equal("\x80\xfc\b\xfd\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX", eval('"\<M-' .. nr2char(0x40000000) .. '>"'))
|
call assert_equal("\x80\xfc\b\xfd\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX", eval('"\<M-' .. nr2char(0x40000000) .. '>"'))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for getcurpos() and setpos()
|
||||||
|
func Test_getcurpos_setpos()
|
||||||
|
new
|
||||||
|
call setline(1, ['012345678', '012345678'])
|
||||||
|
normal gg6l
|
||||||
|
let sp = getcurpos()
|
||||||
|
normal 0
|
||||||
|
call setpos('.', sp)
|
||||||
|
normal jyl
|
||||||
|
call assert_equal('6', @")
|
||||||
|
call assert_equal(-1, setpos('.', v:_null_list))
|
||||||
|
call assert_equal(-1, setpos('.', {}))
|
||||||
|
|
||||||
|
let winid = win_getid()
|
||||||
|
normal G$
|
||||||
|
let pos = getcurpos()
|
||||||
|
wincmd w
|
||||||
|
call assert_equal(pos, getcurpos(winid))
|
||||||
|
|
||||||
|
wincmd w
|
||||||
|
close!
|
||||||
|
|
||||||
|
call assert_equal(getcurpos(), getcurpos(0))
|
||||||
|
call assert_equal([0, 0, 0, 0, 0], getcurpos(-1))
|
||||||
|
call assert_equal([0, 0, 0, 0, 0], getcurpos(1999))
|
||||||
|
endfunc
|
||||||
|
|
||||||
func HasDefault(msg = 'msg')
|
func HasDefault(msg = 'msg')
|
||||||
return a:msg
|
return a:msg
|
||||||
endfunc
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user