mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00
vim-patch:8.2.1384: no ATTENTION prompt for :vimgrep first match file
Problem: No ATTENTION prompt for :vimgrep first match file.
Solution: When there is an existing swap file do not keep the dummy buffer.
(closes vim/vim#6649)
8ce4b7ed85
This commit is contained in:
@@ -5068,6 +5068,20 @@ static void vgr_jump_to_match(qf_info_T *qi, int forceit, int *redraw_for_dummy,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return true if "buf" had an existing swap file, the current swap file does
|
||||||
|
// not end in ".swp".
|
||||||
|
static bool existing_swapfile(const buf_T *buf)
|
||||||
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
|
{
|
||||||
|
if (buf->b_ml.ml_mfp != NULL) {
|
||||||
|
const char_u *const fname = buf->b_ml.ml_mfp->mf_fname;
|
||||||
|
const size_t len = STRLEN(fname);
|
||||||
|
|
||||||
|
return fname[len - 1] != 'p' || fname[len - 2] != 'w';
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// ":vimgrep {pattern} file(s)"
|
// ":vimgrep {pattern} file(s)"
|
||||||
// ":vimgrepadd {pattern} file(s)"
|
// ":vimgrepadd {pattern} file(s)"
|
||||||
// ":lvimgrep {pattern} file(s)"
|
// ":lvimgrep {pattern} file(s)"
|
||||||
@@ -5225,7 +5239,9 @@ void ex_vimgrep(exarg_T *eap)
|
|||||||
if (!found_match) {
|
if (!found_match) {
|
||||||
wipe_dummy_buffer(buf, dirname_start);
|
wipe_dummy_buffer(buf, dirname_start);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
} else if (buf != first_match_buf || (flags & VGR_NOJUMP)) {
|
} else if (buf != first_match_buf
|
||||||
|
|| (flags & VGR_NOJUMP)
|
||||||
|
|| existing_swapfile(buf)) {
|
||||||
unload_dummy_buffer(buf, dirname_start);
|
unload_dummy_buffer(buf, dirname_start);
|
||||||
// Keeping the buffer, remove the dummy flag.
|
// Keeping the buffer, remove the dummy flag.
|
||||||
buf->b_flags &= ~BF_DUMMY;
|
buf->b_flags &= ~BF_DUMMY;
|
||||||
|
@@ -78,6 +78,9 @@ set encoding=utf-8
|
|||||||
let s:test_script_fname = expand('%')
|
let s:test_script_fname = expand('%')
|
||||||
au! SwapExists * call HandleSwapExists()
|
au! SwapExists * call HandleSwapExists()
|
||||||
func HandleSwapExists()
|
func HandleSwapExists()
|
||||||
|
if exists('g:ignoreSwapExists')
|
||||||
|
return
|
||||||
|
endif
|
||||||
" Ignore finding a swap file for the test script (the user might be
|
" Ignore finding a swap file for the test script (the user might be
|
||||||
" editing it and do ":make test_name") and the output file.
|
" editing it and do ":make test_name") and the output file.
|
||||||
" Report finding another swap file and chose 'q' to avoid getting stuck.
|
" Report finding another swap file and chose 'q' to avoid getting stuck.
|
||||||
|
@@ -2568,6 +2568,26 @@ func Test_vimgrep_incsearch()
|
|||||||
set noincsearch
|
set noincsearch
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_vimgrep_existing_swapfile()
|
||||||
|
call writefile(['match apple with apple'], 'Xapple')
|
||||||
|
call writefile(['swapfile'], '.Xapple.swp')
|
||||||
|
let g:foundSwap = 0
|
||||||
|
let g:ignoreSwapExists = 1
|
||||||
|
augroup grep
|
||||||
|
au SwapExists * let foundSwap = 1 | let v:swapchoice = 'e'
|
||||||
|
augroup END
|
||||||
|
vimgrep apple Xapple
|
||||||
|
call assert_equal(1, g:foundSwap)
|
||||||
|
call assert_match('.Xapple.swo', swapname(''))
|
||||||
|
|
||||||
|
call delete('Xapple')
|
||||||
|
call delete('Xapple.swp')
|
||||||
|
augroup grep
|
||||||
|
au! SwapExists
|
||||||
|
augroup END
|
||||||
|
unlet g:ignoreSwapExists
|
||||||
|
endfunc
|
||||||
|
|
||||||
func XfreeTests(cchar)
|
func XfreeTests(cchar)
|
||||||
call s:setup_commands(a:cchar)
|
call s:setup_commands(a:cchar)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user