Merge pull request #13307 from janlazo/vim-8.1.0777

vim-patch:8.1.{323,777,933,938},8.2.{178,248,547,581,592,646,658,793,1608,1975,1991,1992,1993,1994,1998,1999,2003,2007,2008,2009}
This commit is contained in:
Jan Edmund Lazo 2020-11-21 10:52:16 -05:00 committed by GitHub
commit e192a4600a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 61 additions and 187 deletions

View File

@ -1132,12 +1132,6 @@ struct VimMenu {
vimmenu_T *next; ///< Next item in menu
};
typedef struct {
int wb_startcol;
int wb_endcol;
vimmenu_T *wb_menu;
} winbar_item_T;
/// Structure which contains all information that belongs to a window.
///
/// All row numbers are relative to the start of the window, except w_winrow.
@ -1354,10 +1348,6 @@ struct window_S {
char_u *w_localdir; /* absolute path of local directory or
NULL */
vimmenu_T *w_winbar; // The root of the WinBar menu hierarchy.
winbar_item_T *w_winbar_items; // list of items in the WinBar
int w_winbar_height; // 1 if there is a window toolbar
// Options local to a window.
// They are local because they influence the layout of the window or
// depend on the window layout.

View File

@ -6433,7 +6433,7 @@ dict_T *get_win_info(win_T *wp, int16_t tpnr, int16_t winnr)
tv_dict_add_nr(dict, S_LEN("winrow"), wp->w_winrow + 1);
tv_dict_add_nr(dict, S_LEN("topline"), wp->w_topline);
tv_dict_add_nr(dict, S_LEN("botline"), wp->w_botline - 1);
tv_dict_add_nr(dict, S_LEN("winbar"), wp->w_winbar_height);
tv_dict_add_nr(dict, S_LEN("winbar"), 0);
tv_dict_add_nr(dict, S_LEN("width"), wp->w_width);
tv_dict_add_nr(dict, S_LEN("bufnr"), wp->w_buffer->b_fnum);
tv_dict_add_nr(dict, S_LEN("wincol"), wp->w_wincol + 1);

View File

@ -2987,11 +2987,12 @@ static void f_getchar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
// illegal argument or getchar(0) and no char avail: return zero
n = 0;
} else {
// getchar(0) and char avail: return char
// getchar(0) and char avail() != NUL: get a character.
// Note that vpeekc_any() returns K_SPECIAL for K_IGNORE.
n = safe_vgetc();
}
if (n == K_IGNORE) {
if (n == K_IGNORE || n == K_VER_SCROLLBAR || n == K_HOR_SCROLLBAR) {
continue;
}
break;

View File

@ -55,16 +55,10 @@ static bool menu_is_winbar(const char_u *const name)
return (STRNCMP(name, "WinBar", 6) == 0);
}
int winbar_height(const win_T *const wp)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
return wp->w_winbar != NULL && wp->w_winbar->children != NULL ? 1 : 0;
}
static vimmenu_T **get_root_menu(const char_u *const name)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
return menu_is_winbar(name) ? &curwin->w_winbar : &root_menu;
return &root_menu;
}
/// Do the :menu command and relatives.
@ -191,10 +185,6 @@ ex_menu(exarg_T *eap)
}
vimmenu_T **root_menu_ptr = get_root_menu(menu_path);
if (root_menu_ptr == &curwin->w_winbar) {
// Assume the window toolbar menu will change.
redraw_later(curwin, NOT_VALID);
}
if (enable != kNone) {
// Change sensitivity of the menu.
@ -270,19 +260,6 @@ ex_menu(exarg_T *eap)
xfree(map_buf);
}
if (root_menu_ptr == &curwin->w_winbar) {
const int h = winbar_height(curwin);
if (h != curwin->w_winbar_height) {
if (h == 0) {
curwin->w_height++;
} else if (curwin->w_height > 0) {
curwin->w_height--;
}
curwin->w_winbar_height = h;
}
}
ui_call_update_menu();
theend:
@ -661,14 +638,6 @@ remove_menu (
return OK;
}
// Remove the WinBar menu from window "wp".
void remove_winbar(win_T *wp)
FUNC_ATTR_NONNULL_ALL
{
remove_menu(&wp->w_winbar, (char_u *)"", MENU_ALL_MODES, true);
xfree(wp->w_winbar_items);
}
/*
* Free the given menu structure and remove it from the linked list.
*/
@ -937,7 +906,6 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
* Used when expanding menu names.
*/
static vimmenu_T *expand_menu = NULL;
static vimmenu_T *expand_menu_alt = NULL;
static int expand_modes = 0x0;
static int expand_emenu; /* TRUE for ":emenu" command */
@ -992,8 +960,6 @@ char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forc
return NULL; // TODO(vim): check for next command?
}
if (*p == NUL) { // Complete the menu name
bool try_alt_menu = true;
// With :unmenu, you only want to match menus for the appropriate mode.
// With :menu though you might want to add a menu with the same name as
// one in another mode, so match menus from other modes too.
@ -1025,10 +991,6 @@ char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forc
break;
}
menu = menu->next;
if (menu == NULL && try_alt_menu) {
menu = curwin->w_winbar;
try_alt_menu = false;
}
}
if (menu == NULL) {
/* No menu found with the name we were looking for */
@ -1037,18 +999,12 @@ char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forc
}
name = p;
menu = menu->children;
try_alt_menu = false;
}
xfree(path_name);
xp->xp_context = expand_menus ? EXPAND_MENUNAMES : EXPAND_MENUS;
xp->xp_pattern = after_dot;
expand_menu = menu;
if (expand_menu == root_menu) {
expand_menu_alt = curwin->w_winbar;
} else {
expand_menu_alt = NULL;
}
} else { // We're in the mapping part
xp->xp_context = EXPAND_NOTHING;
}
@ -1062,13 +1018,11 @@ char_u *set_context_in_menu_cmd(expand_T *xp, char_u *cmd, char_u *arg, int forc
char_u *get_menu_name(expand_T *xp, int idx)
{
static vimmenu_T *menu = NULL;
static bool did_alt_menu = false;
char_u *str;
static int should_advance = FALSE;
if (idx == 0) { /* first call: start at first item */
menu = expand_menu;
did_alt_menu = false;
should_advance = false;
}
@ -1077,10 +1031,6 @@ char_u *get_menu_name(expand_T *xp, int idx)
|| menu_is_separator(menu->dname)
|| menu->children == NULL)) {
menu = menu->next;
if (menu == NULL && !did_alt_menu) {
menu = expand_menu_alt;
did_alt_menu = true;
}
}
if (menu == NULL) /* at end of linked list */
@ -1100,10 +1050,6 @@ char_u *get_menu_name(expand_T *xp, int idx)
if (should_advance) {
// Advance to next menu entry.
menu = menu->next;
if (menu == NULL && !did_alt_menu) {
menu = expand_menu_alt;
did_alt_menu = true;
}
}
should_advance = !should_advance;
@ -1118,7 +1064,6 @@ char_u *get_menu_name(expand_T *xp, int idx)
char_u *get_menu_names(expand_T *xp, int idx)
{
static vimmenu_T *menu = NULL;
static bool did_alt_menu = false;
#define TBUFFER_LEN 256
static char_u tbuffer[TBUFFER_LEN]; /*hack*/
char_u *str;
@ -1126,7 +1071,6 @@ char_u *get_menu_names(expand_T *xp, int idx)
if (idx == 0) { /* first call: start at first item */
menu = expand_menu;
did_alt_menu = false;
should_advance = false;
}
@ -1136,10 +1080,6 @@ char_u *get_menu_names(expand_T *xp, int idx)
|| (expand_emenu && menu_is_separator(menu->dname))
|| menu->dname[STRLEN(menu->dname) - 1] == '.')) {
menu = menu->next;
if (menu == NULL && !did_alt_menu) {
menu = expand_menu_alt;
did_alt_menu = true;
}
}
if (menu == NULL) /* at end of linked list */
@ -1173,10 +1113,6 @@ char_u *get_menu_names(expand_T *xp, int idx)
if (should_advance) {
// Advance to next menu entry.
menu = menu->next;
if (menu == NULL && !did_alt_menu) {
menu = expand_menu_alt;
did_alt_menu = true;
}
}
should_advance = !should_advance;
@ -1470,7 +1406,6 @@ static void execute_menu(const exarg_T *eap, vimmenu_T *menu)
}
}
// For the WinBar menu always use the Normal mode menu.
if (idx == -1 || eap == NULL) {
mode = (char_u *)"Normal";
idx = MENU_INDEX_NORMAL;
@ -1540,53 +1475,6 @@ void ex_emenu(exarg_T *eap)
execute_menu(eap, menu);
}
// Handle a click in the window toolbar of "wp" at column "col".
void winbar_click(win_T *wp, int col)
FUNC_ATTR_NONNULL_ALL
{
if (wp->w_winbar_items == NULL) {
return;
}
for (int idx = 0; wp->w_winbar_items[idx].wb_menu != NULL; idx++) {
winbar_item_T *item = &wp->w_winbar_items[idx];
if (col >= item->wb_startcol && col <= item->wb_endcol) {
win_T *save_curwin = NULL;
const pos_T save_visual = VIsual;
const int save_visual_active = VIsual_active;
const int save_visual_select = VIsual_select;
const int save_visual_reselect = VIsual_reselect;
const int save_visual_mode = VIsual_mode;
if (wp != curwin) {
// Clicking in the window toolbar of a not-current window.
// Make that window the current one and save Visual mode.
save_curwin = curwin;
VIsual_active = false;
curwin = wp;
curbuf = curwin->w_buffer;
check_cursor();
}
// Note: the command might close the current window.
execute_menu(NULL, item->wb_menu);
if (save_curwin != NULL && win_valid(save_curwin)) {
curwin = save_curwin;
curbuf = curwin->w_buffer;
VIsual = save_visual;
VIsual_active = save_visual_active;
VIsual_select = save_visual_select;
VIsual_reselect = save_visual_reselect;
VIsual_mode = save_visual_mode;
}
if (!win_valid(wp)) {
break;
}
}
}
}
/*
* Translation of menu names. Just a simple lookup table.
*/

View File

@ -60,7 +60,6 @@ int jump_to_mouse(int flags,
{
static int on_status_line = 0; // #lines below bottom of window
static int on_sep_line = 0; // on separator right of window
static bool in_winbar = false;
static int prev_row = -1;
static int prev_col = -1;
static win_T *dragwin = NULL; // window being dragged
@ -101,18 +100,6 @@ retnomove:
if (on_sep_line) {
return IN_SEP_LINE;
}
if (in_winbar) {
// A quick second click may arrive as a double-click, but we use it
// as a second click in the WinBar.
if ((mod_mask & MOD_MASK_MULTI_CLICK) && !(flags & MOUSE_RELEASED)) {
wp = mouse_find_win(&grid, &row, &col);
if (wp == NULL) {
return IN_UNKNOWN;
}
winbar_click(wp, col);
}
return IN_OTHER_WIN | MOUSE_WINBAR;
}
if (flags & MOUSE_MAY_STOP_VIS) {
end_visual_mode();
redraw_curbuf_later(INVERTED); // delete the inversion
@ -142,13 +129,8 @@ retnomove:
dragwin = NULL;
if (row == -1) {
// A click in the window toolbar does not enter another window or
// change Visual highlighting.
winbar_click(wp, col);
in_winbar = true;
return IN_OTHER_WIN | MOUSE_WINBAR;
return IN_OTHER_WIN;
}
in_winbar = false;
// winpos and height may change in win_enter()!
if (grid == DEFAULT_GRID_HANDLE && row >= wp->w_height) {
@ -239,9 +221,6 @@ retnomove:
did_drag |= count;
}
return IN_SEP_LINE; // Cursor didn't move
} else if (in_winbar) {
// After a click on the window toolbar don't start Visual mode.
return IN_OTHER_WIN | MOUSE_WINBAR;
} else {
// keep_window_focus must be true
// before moving the cursor for a left click, stop Visual mode
@ -503,7 +482,6 @@ win_T *mouse_find_win(int *gridp, int *rowp, int *colp)
// exist.
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp == fp->fr_win) {
*rowp -= wp->w_winbar_height;
return wp;
}
}

View File

@ -2601,11 +2601,6 @@ do_mouse (
oap == NULL ? NULL : &(oap->inclusive),
which_button);
// A click in the window toolbar has no side effects.
if (jump_flags & MOUSE_WINBAR) {
return false;
}
moved = (jump_flags & CURSOR_MOVED);
in_status_line = (jump_flags & IN_STATUS_LINE);
in_sep_line = (jump_flags & IN_SEP_LINE);

View File

@ -1112,8 +1112,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
// add a status line when p_ls == 1 and splitting the first window
if (one_nonfloat() && p_ls == 1 && oldwin->w_status_height == 0) {
if ((oldwin->w_height + oldwin->w_winbar_height) <= p_wmh
&& new_in_layout) {
if (oldwin->w_height <= p_wmh && new_in_layout) {
EMSG(_(e_noroom));
return FAIL;
}
@ -1210,7 +1209,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
* height.
*/
// Current window requires at least 1 space.
wmh1 = (p_wmh == 0 ? 1 : p_wmh) + curwin->w_winbar_height;
wmh1 = p_wmh == 0 ? 1 : p_wmh;
needed = wmh1 + STATUS_HEIGHT;
if (flags & WSP_ROOM) {
needed += p_wh - wmh1;
@ -1408,12 +1407,12 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
if (flags & (WSP_TOP | WSP_BOT)) {
/* set height and row of new window to full height */
wp->w_winrow = tabline_height();
win_new_height(wp, curfrp->fr_height - (p_ls > 0) - wp->w_winbar_height);
win_new_height(wp, curfrp->fr_height - (p_ls > 0));
wp->w_status_height = (p_ls > 0);
} else {
/* height and row of new window is same as current window */
wp->w_winrow = oldwin->w_winrow;
win_new_height(wp, oldwin->w_height + oldwin->w_winbar_height);
win_new_height(wp, oldwin->w_height);
wp->w_status_height = oldwin->w_status_height;
}
frp->fr_height = curfrp->fr_height;
@ -1460,7 +1459,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
* one row for the status line */
win_new_height(wp, new_size);
if (flags & (WSP_TOP | WSP_BOT)) {
int new_fr_height = curfrp->fr_height - new_size + wp->w_winbar_height;
int new_fr_height = curfrp->fr_height - new_size;
if (!((flags & WSP_BOT) && p_ls == 0)) {
new_fr_height -= STATUS_HEIGHT;
@ -1474,8 +1473,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
wp->w_status_height = STATUS_HEIGHT;
oldwin->w_winrow += wp->w_height + STATUS_HEIGHT;
} else { // new window below current one
wp->w_winrow = oldwin->w_winrow + oldwin->w_height
+ STATUS_HEIGHT + oldwin->w_winbar_height;
wp->w_winrow = oldwin->w_winrow + oldwin->w_height + STATUS_HEIGHT;
wp->w_status_height = oldwin->w_status_height;
if (!(flags & WSP_BOT)) {
oldwin->w_status_height = STATUS_HEIGHT;
@ -1690,7 +1688,7 @@ make_windows (
- (p_wiw - p_wmw)) / (p_wmw + 1);
} else {
// Each window needs at least 'winminheight' lines and a status line.
maxcount = (curwin->w_height + curwin->w_winbar_height
maxcount = (curwin->w_height
+ curwin->w_status_height
- (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT);
}
@ -3155,9 +3153,7 @@ frame_new_height (
if (topfrp->fr_win != NULL) {
// Simple case: just one window.
win_new_height(topfrp->fr_win,
height
- topfrp->fr_win->w_status_height
- topfrp->fr_win->w_winbar_height);
height - topfrp->fr_win->w_status_height);
} else if (topfrp->fr_layout == FR_ROW) {
do {
// All frames in this row get the same new height.
@ -3464,8 +3460,7 @@ static void frame_fix_width(win_T *wp)
static void frame_fix_height(win_T *wp)
FUNC_ATTR_NONNULL_ALL
{
wp->w_frame->fr_height =
wp->w_height + wp->w_status_height + wp->w_winbar_height;
wp->w_frame->fr_height = wp->w_height + wp->w_status_height;
}
/*
@ -3488,11 +3483,10 @@ static int frame_minheight(frame_T *topfrp, win_T *next_curwin)
// window: minimal height of the window plus status line
m = p_wmh + topfrp->fr_win->w_status_height;
if (topfrp->fr_win == curwin && next_curwin == NULL) {
// Current window is minimal one line high and WinBar is visible.
// Current window is minimal one line high.
if (p_wmh == 0) {
m++;
}
m += curwin->w_winbar_height;
}
}
} else if (topfrp->fr_layout == FR_ROW) {
@ -4804,8 +4798,6 @@ win_free (
qf_free_all(wp);
remove_winbar(wp);
xfree(wp->w_p_cc_cols);
win_free_grid(wp, false);
@ -5092,8 +5084,7 @@ static void frame_comp_pos(frame_T *topfrp, int *row, int *col)
wp->w_redr_status = true;
wp->w_pos_changed = true;
}
// WinBar will not show if the window height is zero
const int h = wp->w_height + wp->w_winbar_height + wp->w_status_height;
const int h = wp->w_height + wp->w_status_height;
*row += h > topfrp->fr_height ? topfrp->fr_height : h;
*col += wp->w_width + wp->w_vsep_width;
} else {
@ -5135,7 +5126,6 @@ void win_setheight_win(int height, win_T *win)
if (height == 0) {
height = 1;
}
height += curwin->w_winbar_height;
}
if (win->w_floating) {
@ -5231,9 +5221,8 @@ static void frame_setheight(frame_T *curfrp, int height)
room_cmdline = 0;
} else {
win_T *wp = lastwin_nofloating();
room_cmdline = Rows - p_ch - (wp->w_winrow
+ wp->w_height + wp->w_winbar_height +
wp->w_status_height);
room_cmdline = Rows - p_ch
- (wp->w_winrow + wp->w_height + wp->w_status_height);
if (room_cmdline < 0) {
room_cmdline = 0;
}

View File

@ -232,20 +232,53 @@ describe("shell command :!", function()
if has_powershell() then
it('powershell supports literal strings', function()
set_shell_powershell()
local screen = Screen.new(30, 4)
local screen = Screen.new(45, 4)
screen:attach()
feed_command([[!'Write-Output $a']])
screen:expect{any='\nWrite%-Output %$a', timeout=10000}
screen:expect([[
:!'Write-Output $a' |
Write-Output $a |
|
Press ENTER or type command to continue^ |
]])
feed_command([[!$a = 1; Write-Output '$a']])
screen:expect{any='\n%$a', timeout=10000}
screen:expect([[
:!$a = 1; Write-Output '$a' |
$a |
|
Press ENTER or type command to continue^ |
]])
feed_command([[!"Write-Output $a"]])
screen:expect{any='\nWrite%-Output', timeout=10000}
screen:expect([[
:!"Write-Output $a" |
Write-Output |
|
Press ENTER or type command to continue^ |
]])
feed_command([[!$a = 1; Write-Output "$a"]])
screen:expect{any='\n1', timeout=10000}
feed_command(iswin()
and [[!& 'C:\\Windows\\system32\\cmd.exe' /c 'echo $a']]
or [[!& '/bin/sh' -c 'echo ''$a''']])
screen:expect{any='\n%$a', timeout=10000}
screen:expect([[
:!$a = 1; Write-Output "$a" |
1 |
|
Press ENTER or type command to continue^ |
]])
if iswin() then
feed_command([[!& 'cmd.exe' /c 'echo $a']])
screen:expect([[
:!& 'cmd.exe' /c 'echo $a' |
$a |
|
Press ENTER or type command to continue^ |
]])
else
feed_command([[!& '/bin/sh' -c 'echo ''$a''']])
screen:expect([[
:!& '/bin/sh' -c 'echo ''$a''' |
$a |
|
Press ENTER or type command to continue^ |
]])
end
end)
end
end)