mirror of
https://github.com/neovim/neovim.git
synced 2025-11-23 02:26:30 +00:00
Merge #11616 from janlazo/vim-8.0.1491
vim-patch:8.0.{1356,1491,1495,1522,1538,1540},8.1.{554,670,1300,1303,1875,2377}
This commit is contained in:
@@ -583,13 +583,6 @@ ColorSchemePre Before loading a color scheme. |:colorscheme|
|
|||||||
Useful to setup removing things added by a
|
Useful to setup removing things added by a
|
||||||
color scheme, before another one is loaded.
|
color scheme, before another one is loaded.
|
||||||
|
|
||||||
*CompleteDone*
|
|
||||||
CompleteDone After Insert mode completion is done. Either
|
|
||||||
when something was completed or abandoning
|
|
||||||
completion. |ins-completion|
|
|
||||||
The |v:completed_item| variable contains the
|
|
||||||
completed item.
|
|
||||||
|
|
||||||
CompleteChanged *CompleteChanged*
|
CompleteChanged *CompleteChanged*
|
||||||
After each time the Insert mode completion
|
After each time the Insert mode completion
|
||||||
menu changed. Not fired on popup menu hide,
|
menu changed. Not fired on popup menu hide,
|
||||||
@@ -610,6 +603,13 @@ CompleteChanged *CompleteChanged*
|
|||||||
The size and position of the popup are also
|
The size and position of the popup are also
|
||||||
available by calling |pum_getpos()|.
|
available by calling |pum_getpos()|.
|
||||||
|
|
||||||
|
*CompleteDone*
|
||||||
|
CompleteDone After Insert mode completion is done. Either
|
||||||
|
when something was completed or abandoning
|
||||||
|
completion. |ins-completion|
|
||||||
|
The |v:completed_item| variable contains the
|
||||||
|
completed item.
|
||||||
|
|
||||||
*CursorHold*
|
*CursorHold*
|
||||||
CursorHold When the user doesn't press a key for the time
|
CursorHold When the user doesn't press a key for the time
|
||||||
specified with 'updatetime'. Not re-triggered
|
specified with 'updatetime'. Not re-triggered
|
||||||
|
|||||||
@@ -3121,8 +3121,9 @@ complete_info([{what}])
|
|||||||
the items listed in {what} are returned. Unsupported items in
|
the items listed in {what} are returned. Unsupported items in
|
||||||
{what} are silently ignored.
|
{what} are silently ignored.
|
||||||
|
|
||||||
To get the position of the popup menu, see |pum_getpos()|. It's
|
To get the position and size of the popup menu, see
|
||||||
also available in |v:event| during the |CompleteChanged| event.
|
|pum_getpos()|. It's also available in |v:event| during the
|
||||||
|
|CompleteChanged| event.
|
||||||
|
|
||||||
Examples: >
|
Examples: >
|
||||||
" Get all items
|
" Get all items
|
||||||
@@ -3770,6 +3771,8 @@ feedkeys({string} [, {mode}]) *feedkeys()*
|
|||||||
and "\..." notation |expr-quote|. For example,
|
and "\..." notation |expr-quote|. For example,
|
||||||
feedkeys("\<CR>") simulates pressing of the <Enter> key. But
|
feedkeys("\<CR>") simulates pressing of the <Enter> key. But
|
||||||
feedkeys('\<CR>') pushes 5 characters.
|
feedkeys('\<CR>') pushes 5 characters.
|
||||||
|
A special code that might be useful is <Ignore>, it exits the
|
||||||
|
wait for a character without doing anything. *<Ignore>*
|
||||||
|
|
||||||
{mode} is a String, which can contain these character flags:
|
{mode} is a String, which can contain these character flags:
|
||||||
'm' Remap keys. This is default. If {mode} is absent,
|
'm' Remap keys. This is default. If {mode} is absent,
|
||||||
|
|||||||
@@ -4524,13 +4524,6 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
global
|
global
|
||||||
When on a ":" prompt is used in Ex mode.
|
When on a ":" prompt is used in Ex mode.
|
||||||
|
|
||||||
*'pumheight'* *'ph'*
|
|
||||||
'pumheight' 'ph' number (default 0)
|
|
||||||
global
|
|
||||||
Determines the maximum number of items to show in the popup menu for
|
|
||||||
Insert mode completion. When zero as much space as available is used.
|
|
||||||
|ins-completion-menu|.
|
|
||||||
|
|
||||||
*'pumblend'* *'pb'*
|
*'pumblend'* *'pb'*
|
||||||
'pumblend' 'pb' number (default 0)
|
'pumblend' 'pb' number (default 0)
|
||||||
global
|
global
|
||||||
@@ -4547,6 +4540,19 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
<
|
<
|
||||||
UI-dependent. Works best with RGB colors. 'termguicolors'
|
UI-dependent. Works best with RGB colors. 'termguicolors'
|
||||||
|
|
||||||
|
*'pumheight'* *'ph'*
|
||||||
|
'pumheight' 'ph' number (default 0)
|
||||||
|
global
|
||||||
|
Determines the maximum number of items to show in the popup menu for
|
||||||
|
Insert mode completion. When zero as much space as available is used.
|
||||||
|
|ins-completion-menu|.
|
||||||
|
|
||||||
|
*'pumwidth'* *'pw'*
|
||||||
|
'pumwidth' 'pw' number (default 15)
|
||||||
|
global
|
||||||
|
Determines the minium width to use for the popup menu for Insert mode
|
||||||
|
completion. |ins-completion-menu|.
|
||||||
|
|
||||||
*'pyxversion'* *'pyx'*
|
*'pyxversion'* *'pyx'*
|
||||||
'pyxversion' 'pyx' number (default depends on the build)
|
'pyxversion' 'pyx' number (default depends on the build)
|
||||||
global
|
global
|
||||||
|
|||||||
@@ -430,9 +430,11 @@ _set_tokens_and_tags() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Prints a newline-delimited list of Vim commits, for use by scripts.
|
||||||
# "$1": use extended format?
|
# "$1": use extended format?
|
||||||
# "$@" is passed to list_vim_commits, as extra arguments to git-log.
|
# "$@" is passed to list_vim_commits, as extra arguments to git-log.
|
||||||
list_missing_vimpatches() {
|
list_missing_vimpatches() {
|
||||||
|
local -a missing_vim_patches=()
|
||||||
_set_missing_vimpatches "$@"
|
_set_missing_vimpatches "$@"
|
||||||
set +u # Avoid "unbound variable" with bash < 4.4 below.
|
set +u # Avoid "unbound variable" with bash < 4.4 below.
|
||||||
for line in "${missing_vim_patches[@]}"; do
|
for line in "${missing_vim_patches[@]}"; do
|
||||||
|
|||||||
@@ -638,7 +638,7 @@ static int insert_check(VimState *state)
|
|||||||
|
|
||||||
static int insert_execute(VimState *state, int key)
|
static int insert_execute(VimState *state, int key)
|
||||||
{
|
{
|
||||||
if (key == K_IGNORE) {
|
if (key == K_IGNORE || key == K_NOP) {
|
||||||
return -1; // get another key
|
return -1; // get another key
|
||||||
}
|
}
|
||||||
InsertState *s = (InsertState *)state;
|
InsertState *s = (InsertState *)state;
|
||||||
|
|||||||
@@ -536,7 +536,7 @@ static int command_line_check(VimState *state)
|
|||||||
|
|
||||||
static int command_line_execute(VimState *state, int key)
|
static int command_line_execute(VimState *state, int key)
|
||||||
{
|
{
|
||||||
if (key == K_IGNORE) {
|
if (key == K_IGNORE || key == K_NOP) {
|
||||||
return -1; // get another key
|
return -1; // get another key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -309,6 +309,7 @@ static const struct key_name_entry {
|
|||||||
{ K_ZERO, "Nul" },
|
{ K_ZERO, "Nul" },
|
||||||
{ K_SNR, "SNR" },
|
{ K_SNR, "SNR" },
|
||||||
{ K_PLUG, "Plug" },
|
{ K_PLUG, "Plug" },
|
||||||
|
{ K_IGNORE, "Ignore" },
|
||||||
{ K_COMMAND, "Cmd" },
|
{ K_COMMAND, "Cmd" },
|
||||||
{ 0, NULL }
|
{ 0, NULL }
|
||||||
// NOTE: When adding a long name update MAX_KEY_NAME_LEN.
|
// NOTE: When adding a long name update MAX_KEY_NAME_LEN.
|
||||||
|
|||||||
@@ -874,8 +874,10 @@ static void normal_finish_command(NormalState *s)
|
|||||||
s->old_mapped_len = typebuf_maplen();
|
s->old_mapped_len = typebuf_maplen();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If an operation is pending, handle it...
|
// If an operation is pending, handle it. But not for K_IGNORE.
|
||||||
|
if (s->ca.cmdchar != K_IGNORE) {
|
||||||
do_pending_operator(&s->ca, s->old_col, false);
|
do_pending_operator(&s->ca, s->old_col, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Wait for a moment when a message is displayed that will be overwritten
|
// Wait for a moment when a message is displayed that will be overwritten
|
||||||
// by the mode message.
|
// by the mode message.
|
||||||
|
|||||||
@@ -371,8 +371,9 @@ EXTERN long p_columns; // 'columns'
|
|||||||
EXTERN int p_confirm; // 'confirm'
|
EXTERN int p_confirm; // 'confirm'
|
||||||
EXTERN int p_cp; // 'compatible'
|
EXTERN int p_cp; // 'compatible'
|
||||||
EXTERN char_u *p_cot; // 'completeopt'
|
EXTERN char_u *p_cot; // 'completeopt'
|
||||||
EXTERN long p_ph; // 'pumheight'
|
|
||||||
EXTERN long p_pb; // 'pumblend'
|
EXTERN long p_pb; // 'pumblend'
|
||||||
|
EXTERN long p_ph; // 'pumheight'
|
||||||
|
EXTERN long p_pw; // 'pumwidth'
|
||||||
EXTERN char_u *p_cpo; // 'cpoptions'
|
EXTERN char_u *p_cpo; // 'cpoptions'
|
||||||
EXTERN char_u *p_csprg; // 'cscopeprg'
|
EXTERN char_u *p_csprg; // 'cscopeprg'
|
||||||
EXTERN int p_csre; // 'cscoperelative'
|
EXTERN int p_csre; // 'cscoperelative'
|
||||||
|
|||||||
@@ -1815,6 +1815,14 @@ return {
|
|||||||
varname='p_prompt',
|
varname='p_prompt',
|
||||||
defaults={if_true={vi=true}}
|
defaults={if_true={vi=true}}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
full_name='pumblend', abbreviation='pb',
|
||||||
|
type='number', scope={'global'},
|
||||||
|
vi_def=true,
|
||||||
|
redraw={'ui_option'},
|
||||||
|
varname='p_pb',
|
||||||
|
defaults={if_true={vi=0}}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
full_name='pumheight', abbreviation='ph',
|
full_name='pumheight', abbreviation='ph',
|
||||||
type='number', scope={'global'},
|
type='number', scope={'global'},
|
||||||
@@ -1823,12 +1831,11 @@ return {
|
|||||||
defaults={if_true={vi=0}}
|
defaults={if_true={vi=0}}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='pumblend', abbreviation='pb',
|
full_name='pumwidth', abbreviation='pw',
|
||||||
type='number', scope={'global'},
|
type='number', scope={'global'},
|
||||||
vi_def=true,
|
vi_def=true,
|
||||||
redraw={'ui_option'},
|
varname='p_pw',
|
||||||
varname='p_pb',
|
defaults={if_true={vi=15}}
|
||||||
defaults={if_true={vi=0}}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
full_name='pyxversion', abbreviation='pyx',
|
full_name='pyxversion', abbreviation='pyx',
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ static bool pum_invalid = false; // the screen was just cleared
|
|||||||
# include "popupmnu.c.generated.h"
|
# include "popupmnu.c.generated.h"
|
||||||
#endif
|
#endif
|
||||||
#define PUM_DEF_HEIGHT 10
|
#define PUM_DEF_HEIGHT 10
|
||||||
#define PUM_DEF_WIDTH 15
|
|
||||||
|
|
||||||
static void pum_compute_size(void)
|
static void pum_compute_size(void)
|
||||||
{
|
{
|
||||||
@@ -84,7 +83,7 @@ static void pum_compute_size(void)
|
|||||||
|
|
||||||
/// Show the popup menu with items "array[size]".
|
/// Show the popup menu with items "array[size]".
|
||||||
/// "array" must remain valid until pum_undisplay() is called!
|
/// "array" must remain valid until pum_undisplay() is called!
|
||||||
/// When possible the leftmost character is aligned with screen column "col".
|
/// When possible the leftmost character is aligned with cursor column.
|
||||||
/// The menu appears above the screen line "row" or at "row" + "height" - 1.
|
/// The menu appears above the screen line "row" or at "row" + "height" - 1.
|
||||||
///
|
///
|
||||||
/// @param array
|
/// @param array
|
||||||
@@ -97,13 +96,12 @@ static void pum_compute_size(void)
|
|||||||
void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
||||||
int cmd_startcol)
|
int cmd_startcol)
|
||||||
{
|
{
|
||||||
int def_width;
|
|
||||||
int context_lines;
|
int context_lines;
|
||||||
int above_row;
|
int above_row;
|
||||||
int below_row;
|
int below_row;
|
||||||
int redo_count = 0;
|
int redo_count = 0;
|
||||||
int row;
|
int pum_win_row;
|
||||||
int col;
|
int cursor_col;
|
||||||
|
|
||||||
if (!pum_is_visible) {
|
if (!pum_is_visible) {
|
||||||
// To keep the code simple, we only allow changing the
|
// To keep the code simple, we only allow changing the
|
||||||
@@ -123,23 +121,23 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
|||||||
|
|
||||||
// wildoptions=pum
|
// wildoptions=pum
|
||||||
if (State == CMDLINE) {
|
if (State == CMDLINE) {
|
||||||
row = ui_has(kUICmdline) ? 0 : cmdline_row;
|
pum_win_row = ui_has(kUICmdline) ? 0 : cmdline_row;
|
||||||
col = cmd_startcol;
|
cursor_col = cmd_startcol;
|
||||||
pum_anchor_grid = ui_has(kUICmdline) ? -1 : DEFAULT_GRID_HANDLE;
|
pum_anchor_grid = ui_has(kUICmdline) ? -1 : DEFAULT_GRID_HANDLE;
|
||||||
} else {
|
} else {
|
||||||
// anchor position: the start of the completed word
|
// anchor position: the start of the completed word
|
||||||
row = curwin->w_wrow;
|
pum_win_row = curwin->w_wrow;
|
||||||
if (curwin->w_p_rl) {
|
if (curwin->w_p_rl) {
|
||||||
col = curwin->w_width - curwin->w_wcol - 1;
|
cursor_col = curwin->w_width - curwin->w_wcol - 1;
|
||||||
} else {
|
} else {
|
||||||
col = curwin->w_wcol;
|
cursor_col = curwin->w_wcol;
|
||||||
}
|
}
|
||||||
|
|
||||||
pum_anchor_grid = (int)curwin->w_grid.handle;
|
pum_anchor_grid = (int)curwin->w_grid.handle;
|
||||||
if (!ui_has(kUIMultigrid)) {
|
if (!ui_has(kUIMultigrid)) {
|
||||||
pum_anchor_grid = (int)default_grid.handle;
|
pum_anchor_grid = (int)default_grid.handle;
|
||||||
row += curwin->w_winrow;
|
pum_win_row += curwin->w_winrow;
|
||||||
col += curwin->w_wincol;
|
cursor_col += curwin->w_wincol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,14 +152,15 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
|||||||
ADD(item, STRING_OBJ(cstr_to_string((char *)array[i].pum_info)));
|
ADD(item, STRING_OBJ(cstr_to_string((char *)array[i].pum_info)));
|
||||||
ADD(arr, ARRAY_OBJ(item));
|
ADD(arr, ARRAY_OBJ(item));
|
||||||
}
|
}
|
||||||
ui_call_popupmenu_show(arr, selected, row, col, pum_anchor_grid);
|
ui_call_popupmenu_show(arr, selected, pum_win_row, cursor_col,
|
||||||
|
pum_anchor_grid);
|
||||||
} else {
|
} else {
|
||||||
ui_call_popupmenu_select(selected);
|
ui_call_popupmenu_select(selected);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def_width = PUM_DEF_WIDTH;
|
int def_width = (int)p_pw;
|
||||||
|
|
||||||
win_T *pvwin = NULL;
|
win_T *pvwin = NULL;
|
||||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||||
@@ -190,11 +189,11 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
|||||||
pum_height = (int)p_ph;
|
pum_height = (int)p_ph;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the pum below "row" if possible. If there are few lines decide on
|
// Put the pum below "pum_win_row" if possible.
|
||||||
// where there is more room.
|
// If there are few lines decide on where there is more room.
|
||||||
if (row + 2 >= below_row - pum_height
|
if (pum_win_row + 2 >= below_row - pum_height
|
||||||
&& row - above_row > (below_row - above_row) / 2) {
|
&& pum_win_row - above_row > (below_row - above_row) / 2) {
|
||||||
// pum above "row"
|
// pum above "pum_win_row"
|
||||||
pum_above = true;
|
pum_above = true;
|
||||||
|
|
||||||
// Leave two lines of context if possible
|
// Leave two lines of context if possible
|
||||||
@@ -204,12 +203,12 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
|||||||
context_lines = curwin->w_wrow - curwin->w_cline_row;
|
context_lines = curwin->w_wrow - curwin->w_cline_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row >= size + context_lines) {
|
if (pum_win_row >= size + context_lines) {
|
||||||
pum_row = row - size - context_lines;
|
pum_row = pum_win_row - size - context_lines;
|
||||||
pum_height = size;
|
pum_height = size;
|
||||||
} else {
|
} else {
|
||||||
pum_row = 0;
|
pum_row = 0;
|
||||||
pum_height = row - context_lines;
|
pum_height = pum_win_row - context_lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((p_ph > 0) && (pum_height > p_ph)) {
|
if ((p_ph > 0) && (pum_height > p_ph)) {
|
||||||
@@ -217,7 +216,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
|||||||
pum_height = (int)p_ph;
|
pum_height = (int)p_ph;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// pum below "row"
|
// pum below "pum_win_row"
|
||||||
pum_above = false;
|
pum_above = false;
|
||||||
|
|
||||||
// Leave two lines of context if possible
|
// Leave two lines of context if possible
|
||||||
@@ -228,7 +227,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
|||||||
+ curwin->w_cline_height - curwin->w_wrow;
|
+ curwin->w_cline_height - curwin->w_wrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
pum_row = row + context_lines;
|
pum_row = pum_win_row + context_lines;
|
||||||
if (size > below_row - pum_row) {
|
if (size > below_row - pum_row) {
|
||||||
pum_height = below_row - pum_row;
|
pum_height = below_row - pum_row;
|
||||||
} else {
|
} else {
|
||||||
@@ -245,16 +244,10 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a preview window above, avoid drawing over it.
|
// If there is a preview window above avoid drawing over it.
|
||||||
// Do keep at least 10 entries.
|
if (pvwin != NULL && pum_row < above_row && pum_height > above_row) {
|
||||||
if (pvwin != NULL && pum_row < above_row && pum_height > 10) {
|
|
||||||
if (row - above_row < 10) {
|
|
||||||
pum_row = row - 10;
|
|
||||||
pum_height = 10;
|
|
||||||
} else {
|
|
||||||
pum_row = above_row;
|
pum_row = above_row;
|
||||||
pum_height = row - above_row;
|
pum_height = pum_win_row - above_row;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (pum_external) {
|
if (pum_external) {
|
||||||
return;
|
return;
|
||||||
@@ -277,11 +270,15 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
|||||||
def_width = max_width;
|
def_width = max_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((((col < Columns - PUM_DEF_WIDTH) || (col < Columns - max_width))
|
if ((((cursor_col < Columns - p_pw)
|
||||||
|
|| (cursor_col < Columns - max_width))
|
||||||
&& !curwin->w_p_rl)
|
&& !curwin->w_p_rl)
|
||||||
|| (curwin->w_p_rl && ((col > PUM_DEF_WIDTH) || (col > max_width)))) {
|
|| (curwin->w_p_rl
|
||||||
// align pum column with "col"
|
&& ((cursor_col > p_pw) || (cursor_col > max_width)))) {
|
||||||
pum_col = col;
|
// align pum with "cursor_col"
|
||||||
|
pum_col = cursor_col;
|
||||||
|
|
||||||
|
// start with the maximum space available
|
||||||
if (curwin->w_p_rl) {
|
if (curwin->w_p_rl) {
|
||||||
pum_width = pum_col - pum_scrollbar + 1;
|
pum_width = pum_col - pum_scrollbar + 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -291,11 +288,60 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((pum_width > max_width + pum_kind_width + pum_extra_width + 1)
|
if ((pum_width > max_width + pum_kind_width + pum_extra_width + 1)
|
||||||
&& (pum_width > PUM_DEF_WIDTH)) {
|
&& (pum_width > p_pw)) {
|
||||||
|
// the width is more than needed for the items, make it
|
||||||
|
// narrower
|
||||||
pum_width = max_width + pum_kind_width + pum_extra_width + 1;
|
pum_width = max_width + pum_kind_width + pum_extra_width + 1;
|
||||||
|
|
||||||
if (pum_width < PUM_DEF_WIDTH) {
|
if (pum_width < p_pw) {
|
||||||
pum_width = PUM_DEF_WIDTH;
|
pum_width = (int)p_pw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (((cursor_col > p_pw || cursor_col > max_width)
|
||||||
|
&& !curwin->w_p_rl)
|
||||||
|
|| (curwin->w_p_rl
|
||||||
|
&& (cursor_col < Columns - p_pw
|
||||||
|
|| cursor_col < Columns - max_width))) {
|
||||||
|
// align pum edge with "cursor_col"
|
||||||
|
if (curwin->w_p_rl
|
||||||
|
&& W_ENDCOL(curwin) < max_width + pum_scrollbar + 1) {
|
||||||
|
pum_col = cursor_col + max_width + pum_scrollbar + 1;
|
||||||
|
if (pum_col >= Columns) {
|
||||||
|
pum_col = Columns - 1;
|
||||||
|
}
|
||||||
|
} else if (!curwin->w_p_rl) {
|
||||||
|
if (curwin->w_wincol > Columns - max_width - pum_scrollbar
|
||||||
|
&& max_width <= p_pw) {
|
||||||
|
// use full width to end of the screen
|
||||||
|
pum_col = cursor_col - max_width - pum_scrollbar;
|
||||||
|
if (pum_col < 0) {
|
||||||
|
pum_col = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curwin->w_p_rl) {
|
||||||
|
pum_width = pum_col - pum_scrollbar + 1;
|
||||||
|
} else {
|
||||||
|
pum_width = Columns - pum_col - pum_scrollbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pum_width < p_pw) {
|
||||||
|
pum_width = (int)p_pw;
|
||||||
|
if (curwin->w_p_rl) {
|
||||||
|
if (pum_width > pum_col) {
|
||||||
|
pum_width = pum_col;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (pum_width >= Columns - pum_col) {
|
||||||
|
pum_width = Columns - pum_col - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (pum_width > max_width + pum_kind_width + pum_extra_width + 1
|
||||||
|
&& pum_width > p_pw) {
|
||||||
|
pum_width = max_width + pum_kind_width + pum_extra_width + 1;
|
||||||
|
if (pum_width < p_pw) {
|
||||||
|
pum_width = (int)p_pw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Columns < def_width) {
|
} else if (Columns < def_width) {
|
||||||
@@ -309,9 +355,9 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed,
|
|||||||
assert(Columns - 1 >= INT_MIN);
|
assert(Columns - 1 >= INT_MIN);
|
||||||
pum_width = (int)(Columns - 1);
|
pum_width = (int)(Columns - 1);
|
||||||
} else {
|
} else {
|
||||||
if (max_width > PUM_DEF_WIDTH) {
|
if (max_width > p_pw) {
|
||||||
// truncate
|
// truncate
|
||||||
max_width = PUM_DEF_WIDTH;
|
max_width = (int)p_pw;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curwin->w_p_rl) {
|
if (curwin->w_p_rl) {
|
||||||
|
|||||||
@@ -121,8 +121,6 @@
|
|||||||
|
|
||||||
#define MB_FILLER_CHAR '<' /* character used when a double-width character
|
#define MB_FILLER_CHAR '<' /* character used when a double-width character
|
||||||
* doesn't fit. */
|
* doesn't fit. */
|
||||||
#define W_ENDCOL(wp) (wp->w_wincol + wp->w_width)
|
|
||||||
#define W_ENDROW(wp) (wp->w_winrow + wp->w_height)
|
|
||||||
|
|
||||||
|
|
||||||
// temporary buffer for rendering a single screenline, so it can be
|
// temporary buffer for rendering a single screenline, so it can be
|
||||||
@@ -2447,8 +2445,6 @@ win_line (
|
|||||||
pos.lnum = lnum;
|
pos.lnum = lnum;
|
||||||
pos.col = search_match_endcol;
|
pos.col = search_match_endcol;
|
||||||
getvcol(curwin, &pos, (colnr_T *)&tocol, NULL, NULL);
|
getvcol(curwin, &pos, (colnr_T *)&tocol, NULL, NULL);
|
||||||
} else {
|
|
||||||
tocol = MAXCOL;
|
|
||||||
}
|
}
|
||||||
// do at least one character; happens when past end of line
|
// do at least one character; happens when past end of line
|
||||||
if (fromcol == tocol) {
|
if (fromcol == tocol) {
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ extern StlClickDefinition *tab_page_click_defs;
|
|||||||
/// Size of the tab_page_click_defs array
|
/// Size of the tab_page_click_defs array
|
||||||
extern long tab_page_click_defs_size;
|
extern long tab_page_click_defs_size;
|
||||||
|
|
||||||
|
#define W_ENDCOL(wp) (wp->w_wincol + wp->w_width)
|
||||||
|
#define W_ENDROW(wp) (wp->w_winrow + wp->w_height)
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "screen.h.generated.h"
|
# include "screen.h.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -733,6 +733,28 @@ func Test_popup_and_preview_autocommand()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_popup_and_previewwindow_dump()
|
||||||
|
if !CanRunVimInTerminal()
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
call writefile([
|
||||||
|
\ 'set previewheight=9',
|
||||||
|
\ 'silent! pedit',
|
||||||
|
\ 'call setline(1, map(repeat(["ab"], 10), "v:val. v:key"))',
|
||||||
|
\ 'exec "norm! G\<C-E>\<C-E>"',
|
||||||
|
\ ], 'Xscript')
|
||||||
|
let buf = RunVimInTerminal('-S Xscript', {})
|
||||||
|
|
||||||
|
" Test that popup and previewwindow do not overlap.
|
||||||
|
call term_sendkeys(buf, "o\<C-X>\<C-N>")
|
||||||
|
sleep 100m
|
||||||
|
call VerifyScreenDump(buf, 'Test_popup_and_previewwindow_01', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "\<Esc>u")
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('Xscript')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_popup_position()
|
func Test_popup_position()
|
||||||
if !CanRunVimInTerminal()
|
if !CanRunVimInTerminal()
|
||||||
return
|
return
|
||||||
@@ -762,6 +784,15 @@ func Test_popup_position()
|
|||||||
call term_sendkeys(buf, "GA\<C-N>")
|
call term_sendkeys(buf, "GA\<C-N>")
|
||||||
call VerifyScreenDump(buf, 'Test_popup_position_03', {'rows': 8})
|
call VerifyScreenDump(buf, 'Test_popup_position_03', {'rows': 8})
|
||||||
|
|
||||||
|
" completed text wider than the window and 'pumwidth' smaller than available
|
||||||
|
" space
|
||||||
|
call term_sendkeys(buf, "\<Esc>u")
|
||||||
|
call term_sendkeys(buf, ":set pumwidth=20\<CR>")
|
||||||
|
call term_sendkeys(buf, "ggI123456789_\<Esc>")
|
||||||
|
call term_sendkeys(buf, "jI123456789_\<Esc>")
|
||||||
|
call term_sendkeys(buf, "GA\<C-N>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_popup_position_04', {'rows': 10})
|
||||||
|
|
||||||
call term_sendkeys(buf, "\<Esc>u")
|
call term_sendkeys(buf, "\<Esc>u")
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('Xtest')
|
call delete('Xtest')
|
||||||
|
|||||||
@@ -739,16 +739,16 @@ describe('builtin popupmenu', function()
|
|||||||
ee |
|
ee |
|
||||||
ff |
|
ff |
|
||||||
gg |
|
gg |
|
||||||
{s:aa } |
|
hh |
|
||||||
{n:bb }{3:iew][+] }|
|
{s:aa }{c: }{3:ew][+] }|
|
||||||
{n:cc } |
|
{n:bb }{c: } |
|
||||||
{n:dd } |
|
{n:cc }{c: } |
|
||||||
{n:ee } |
|
{n:dd }{c: } |
|
||||||
{n:ff } |
|
{n:ee }{c: } |
|
||||||
{n:gg } |
|
{n:ff }{c: } |
|
||||||
{n:hh } |
|
{n:gg }{c: } |
|
||||||
{n:ii } |
|
{n:hh }{c: } |
|
||||||
{n:jj } |
|
{n:ii }{s: } |
|
||||||
aa^ |
|
aa^ |
|
||||||
{4:[No Name] [+] }|
|
{4:[No Name] [+] }|
|
||||||
{2:-- }{5:match 1 of 10} |
|
{2:-- }{5:match 1 of 10} |
|
||||||
@@ -1156,10 +1156,10 @@ describe('builtin popupmenu', function()
|
|||||||
funcs.complete(29, {'word', 'choice', 'text', 'thing'})
|
funcs.complete(29, {'word', 'choice', 'text', 'thing'})
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
some long prefix before the ^ |
|
some long prefix before the ^ |
|
||||||
{1:~ }{n: word }|
|
{n:word }{1: }|
|
||||||
{1:~ }{n: choice}|
|
{n:choice }{1: }|
|
||||||
{1:~ }{n: text }|
|
{n:text }{1: }|
|
||||||
{1:~ }{n: thing }|
|
{n:thing }{1: }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
@@ -1204,10 +1204,10 @@ describe('builtin popupmenu', function()
|
|||||||
feed('<c-p>')
|
feed('<c-p>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
some long prefix before the text|
|
some long prefix before the text|
|
||||||
{1:^~ }{n: word }|
|
{n:^word }{1: }|
|
||||||
{1:~ }{n: choice}|
|
{n:choice }{1: }|
|
||||||
{1:~ }{s: text }|
|
{s:text }{1: }|
|
||||||
{1:~ }{n: thing }|
|
{n:thing }{1: }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
@@ -1301,10 +1301,10 @@ describe('builtin popupmenu', function()
|
|||||||
funcs.complete(29, {'word', 'choice', 'text', 'thing'})
|
funcs.complete(29, {'word', 'choice', 'text', 'thing'})
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
some long prefix before the ^ |
|
some long prefix before the ^ |
|
||||||
{1:~ }{n: word }|
|
{n:word }{1: }|
|
||||||
{1:~ }{n: choice}|
|
{n:choice }{1: }|
|
||||||
{1:~ }{n: text }|
|
{n:text }{1: }|
|
||||||
{1:~ }{n: thing }|
|
{n:thing }{1: }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
@@ -2019,4 +2019,42 @@ describe('builtin popupmenu', function()
|
|||||||
{9:-- Keyword Local completion (^N^P) }{10:match 1 of 3} |
|
{9:-- Keyword Local completion (^N^P) }{10:match 1 of 3} |
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("'pumheight'", function()
|
||||||
|
screen:try_resize(32,8)
|
||||||
|
feed('isome long prefix before the ')
|
||||||
|
command("set completeopt+=noinsert,noselect")
|
||||||
|
command("set linebreak")
|
||||||
|
command("set pumheight=2")
|
||||||
|
funcs.complete(29, {'word', 'choice', 'text', 'thing'})
|
||||||
|
screen:expect([[
|
||||||
|
some long prefix before the ^ |
|
||||||
|
{n:word }{c: }{1: }|
|
||||||
|
{n:choice }{s: }{1: }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{2:-- INSERT --} |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("'pumwidth'", function()
|
||||||
|
screen:try_resize(32,8)
|
||||||
|
feed('isome long prefix before the ')
|
||||||
|
command("set completeopt+=noinsert,noselect")
|
||||||
|
command("set linebreak")
|
||||||
|
command("set pumwidth=8")
|
||||||
|
funcs.complete(29, {'word', 'choice', 'text', 'thing'})
|
||||||
|
screen:expect([[
|
||||||
|
some long prefix before the ^ |
|
||||||
|
{n:word }{1: }|
|
||||||
|
{n:choice }{1: }|
|
||||||
|
{n:text }{1: }|
|
||||||
|
{n:thing }{1: }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{2:-- INSERT --} |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user