Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into tabsidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
rbtnn committed Oct 15, 2024
2 parents e905d85 + 991657e commit 30b993e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ term_start(
buf_T *newbuf;
int vertical = opt->jo_vertical || (cmdmod.cmod_split & WSP_VERT);
jobopt_T orig_opt; // only partly filled
pos_T save_cursor;

if (check_restricted() || check_secure())
return NULL;
Expand Down Expand Up @@ -518,6 +519,7 @@ term_start(
old_curbuf = curbuf;
--curbuf->b_nwindows;
curbuf = buf;
save_cursor = curwin->w_cursor;
curwin->w_buffer = buf;
++curbuf->b_nwindows;
}
Expand Down Expand Up @@ -763,6 +765,7 @@ term_start(
--curbuf->b_nwindows;
curbuf = old_curbuf;
curwin->w_buffer = curbuf;
curwin->w_cursor = save_cursor;
++curbuf->b_nwindows;
}
else if (vgetc_busy
Expand Down
27 changes: 18 additions & 9 deletions src/testdir/test_quickfix.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6462,7 +6462,9 @@ func Test_quickfix_buffer_contents()
call setqflist([], 'f')
endfunc

func Test_quickfix_update()
func XquickfixUpdateTests(cchar)
call s:setup_commands(a:cchar)

" Setup: populate a couple buffers
new
call setline(1, range(1, 5))
Expand All @@ -6472,25 +6474,32 @@ func Test_quickfix_update()
let b2 = bufnr()
" Setup: set a quickfix list.
let items = [{'bufnr': b1, 'lnum': 1}, {'bufnr': b1, 'lnum': 2}, {'bufnr': b2, 'lnum': 1}, {'bufnr': b2, 'lnum': 2}]
call setqflist(items)
call g:Xsetlist(items)

" Open the quickfix list, select the third entry.
copen
Xopen
exe "normal jj\<CR>"
call assert_equal(3, getqflist({'idx' : 0}).idx)
call assert_equal(3, g:Xgetlist({'idx' : 0}).idx)

" Update the quickfix list. Make sure the third entry is still selected.
call setqflist([], 'u', { 'items': items })
call assert_equal(3, getqflist({'idx' : 0}).idx)
call g:Xsetlist([], 'u', { 'items': items })
call assert_equal(3, g:Xgetlist({'idx' : 0}).idx)

" Update the quickfix list again, but this time with missing line number
" information. Confirm that we keep the current buffer selected.
call setqflist([{'bufnr': b1}, {'bufnr': b2}], 'u')
call assert_equal(2, getqflist({'idx' : 0}).idx)
call g:Xsetlist([{'bufnr': b1}, {'bufnr': b2}], 'u')
call assert_equal(2, g:Xgetlist({'idx' : 0}).idx)

Xclose

" Cleanup the buffers we allocated during this test.
%bwipe!
%bwipe!
endfunc

" Test for updating a quickfix list using the "u" flag in setqflist()
func Test_quickfix_update()
call XquickfixUpdateTests('c')
call XquickfixUpdateTests('l')
endfunc

func Test_quickfix_update_with_missing_coordinate_info()
Expand Down
25 changes: 25 additions & 0 deletions src/testdir/test_terminal3.vim
Original file line number Diff line number Diff line change
Expand Up @@ -975,4 +975,29 @@ func Test_terminal_vertical()
call v9.CheckLegacyAndVim9Success(lines)
endfunc

" Needs to come before Test_hidden_terminal(), why?
func Test_autocmd_buffilepost_with_hidden_term()
CheckExecutable true
new XTestFile
defer delete('XTestFile')
call setline(1, ['one', 'two', 'three'])
call cursor(3, 10)
augroup TestCursor
au!
autocmd BufFilePost * call setbufvar(3, '&tabstop', 4)
augroup END

let buf = term_start(['true'], #{hidden: 1, term_finish: 'close'})
call term_wait(buf)
redraw!
call assert_equal('XTestFile', bufname('%'))
call assert_equal([0, 3, 5, 0], getpos('.'))

augroup TestCursor
au!
augroup END
augroup! TestCursor
bw! XTestFile
endfunc

" vim: shiftwidth=2 sts=2 expandtab
4 changes: 4 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,10 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
787,
/**/
786,
/**/
785,
/**/
Expand Down

0 comments on commit 30b993e

Please sign in to comment.