Merge #8880 from janlazo/vim-8.0.1331

This commit is contained in:
Justin M. Keyes 2018-08-22 08:40:56 +02:00 committed by GitHub
commit a466bd2927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 106 additions and 21 deletions

View File

@ -7,7 +7,8 @@ func Test_gf_url()
\ "first test for URL://machine.name/tmp/vimtest2a and other text", \ "first test for URL://machine.name/tmp/vimtest2a and other text",
\ "second test for URL://machine.name/tmp/vimtest2b. And other text", \ "second test for URL://machine.name/tmp/vimtest2b. And other text",
\ "third test for URL:\\\\machine.name\\vimtest2c and other text", \ "third test for URL:\\\\machine.name\\vimtest2c and other text",
\ "fourth test for URL:\\\\machine.name\\tmp\\vimtest2d, and other text" \ "fourth test for URL:\\\\machine.name\\tmp\\vimtest2d, and other text",
\ "fifth test for URL://machine.name/tmp?q=vim&opt=yes and other text",
\ ]) \ ])
call cursor(1,1) call cursor(1,1)
call search("^first") call search("^first")
@ -28,6 +29,10 @@ func Test_gf_url()
call search("URL") call search("URL")
call assert_equal("URL:\\\\machine.name\\tmp\\vimtest2d", expand("<cfile>")) call assert_equal("URL:\\\\machine.name\\tmp\\vimtest2d", expand("<cfile>"))
call search("^fifth")
call search("URL")
call assert_equal("URL://machine.name/tmp?q=vim&opt=yes", expand("<cfile>"))
set isf&vim set isf&vim
enew! enew!
endfunc endfunc

View File

@ -122,3 +122,39 @@ func Test_winbuf_close()
call delete('Xtest2') call delete('Xtest2')
call delete('Xtest3') call delete('Xtest3')
endfunc endfunc
" Test that ":close" will respect 'winfixheight' when possible.
func Test_winfixheight_on_close()
set nosplitbelow nosplitright
split | split | vsplit
$wincmd w
setlocal winfixheight
let l:height = winheight(0)
3close
call assert_equal(l:height, winheight(0))
%bwipeout!
setlocal nowinfixheight splitbelow& splitright&
endfunc
" Test that ":close" will respect 'winfixwidth' when possible.
func Test_winfixwidth_on_close()
set nosplitbelow nosplitright
vsplit | vsplit | split
$wincmd w
setlocal winfixwidth
let l:width = winwidth(0)
3close
call assert_equal(l:width, winwidth(0))
%bwipeout!
setlocal nowinfixwidth splitbelow& splitright&
endfunction

View File

@ -565,6 +565,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
int before; int before;
int minheight; int minheight;
int wmh1; int wmh1;
bool did_set_fraction = false;
if (flags & WSP_TOP) if (flags & WSP_TOP)
oldwin = firstwin; oldwin = firstwin;
@ -729,6 +730,11 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
* 'winfixheight' window. Take them from a window above or below * 'winfixheight' window. Take them from a window above or below
* instead, if possible. */ * instead, if possible. */
if (oldwin->w_p_wfh) { if (oldwin->w_p_wfh) {
// Set w_fraction now so that the cursor keeps the same relative
// vertical position using the old height.
set_fraction(oldwin);
did_set_fraction = true;
win_setheight_win(oldwin->w_height + new_size + STATUS_HEIGHT, win_setheight_win(oldwin->w_height + new_size + STATUS_HEIGHT,
oldwin); oldwin);
oldwin_height = oldwin->w_height; oldwin_height = oldwin->w_height;
@ -843,8 +849,9 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
/* Set w_fraction now so that the cursor keeps the same relative /* Set w_fraction now so that the cursor keeps the same relative
* vertical position. */ * vertical position. */
if (oldwin->w_height > 0) if (!did_set_fraction) {
set_fraction(oldwin); set_fraction(oldwin);
}
wp->w_fraction = oldwin->w_fraction; wp->w_fraction = oldwin->w_fraction;
if (flags & WSP_VERT) { if (flags & WSP_VERT) {
@ -2330,14 +2337,14 @@ winframe_remove (
return wp; return wp;
} }
/* // Return a pointer to the frame that will receive the empty screen space that
* Find out which frame is going to get the freed up space when "win" is // is left over after "win" is closed.
* closed. //
* if 'splitbelow'/'splitleft' the space goes to the window above/left. // If 'splitbelow' or 'splitright' is set, the space goes above or to the left
* if 'nosplitbelow'/'nosplitleft' the space goes to the window below/right. // by default. Otherwise, the free space goes below or to the right. The
* This makes opening a window and closing it immediately keep the same window // result is that opening a window and then immediately closing it will
* layout. // preserve the initial window layout. The 'wfh' and 'wfw' settings are
*/ // respected when possible.
static frame_T * static frame_T *
win_altframe ( win_altframe (
win_T *win, win_T *win,
@ -2345,20 +2352,40 @@ win_altframe (
) )
{ {
frame_T *frp; frame_T *frp;
int b;
if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) {
/* Last window in this tab page, will go to next tab page. */
return alt_tabpage()->tp_curwin->w_frame; return alt_tabpage()->tp_curwin->w_frame;
}
frp = win->w_frame; frp = win->w_frame;
if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_ROW)
b = p_spr; if (frp->fr_prev == NULL) {
else
b = p_sb;
if ((!b && frp->fr_next != NULL) || frp->fr_prev == NULL)
return frp->fr_next; return frp->fr_next;
return frp->fr_prev; }
if (frp->fr_next == NULL) {
return frp->fr_prev;
}
frame_T *target_fr = frp->fr_next;
frame_T *other_fr = frp->fr_prev;
if (p_spr || p_sb) {
target_fr = frp->fr_prev;
other_fr = frp->fr_next;
}
// If 'wfh' or 'wfw' is set for the target and not for the alternate
// window, reverse the selection.
if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_ROW) {
if (frame_fixed_width(target_fr) && !frame_fixed_width(other_fr)) {
target_fr = other_fr;
}
} else {
if (frame_fixed_height(target_fr) && !frame_fixed_height(other_fr)) {
target_fr = other_fr;
}
}
return target_fr;
} }
/* /*
@ -4791,10 +4818,13 @@ void win_drag_vsep_line(win_T *dragwin, int offset)
#define FRACTION_MULT 16384L #define FRACTION_MULT 16384L
// Set wp->w_fraction for the current w_wrow and w_height. // Set wp->w_fraction for the current w_wrow and w_height.
// Has no effect when the window is less than two lines.
void set_fraction(win_T *wp) void set_fraction(win_T *wp)
{ {
wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT + wp->w_height / 2) if (wp->w_height > 1) {
wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT + wp->w_height / 2)
/ (long)wp->w_height; / (long)wp->w_height;
}
} }
/* /*
@ -5110,6 +5140,8 @@ file_name_in_line (
{ {
char_u *ptr; char_u *ptr;
size_t len; size_t len;
bool in_type = true;
bool is_url = false;
/* /*
* search forward for what could be the start of a file name * search forward for what could be the start of a file name
@ -5145,7 +5177,19 @@ file_name_in_line (
*/ */
len = 0; len = 0;
while (vim_isfilec(ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ') while (vim_isfilec(ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ')
|| ((options & FNAME_HYP) && path_is_url((char *)ptr + len))) { || ((options & FNAME_HYP) && path_is_url((char *)ptr + len))
|| (is_url && vim_strchr((char_u *)"?&=", ptr[len]) != NULL)) {
// After type:// we also include ?, & and = as valid characters, so that
// http://google.com?q=this&that=ok works.
if ((ptr[len] >= 'A' && ptr[len] <= 'Z')
|| (ptr[len] >= 'a' && ptr[len] <= 'z')) {
if (in_type && path_is_url((char *)ptr + len + 1)) {
is_url = true;
}
} else {
in_type = false;
}
if (ptr[len] == '\\' && ptr[len + 1] == ' ') { if (ptr[len] == '\\' && ptr[len + 1] == ' ') {
// Skip over the "\" in "\ ". // Skip over the "\" in "\ ".
++len; ++len;