mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
Merge pull request #28194 from zeertzjq/vim-9.1.0267
vim-patch:9.1.{0267,0268,0269}
This commit is contained in:
commit
a4e4e493df
@ -203,7 +203,6 @@ void dialog_changed(buf_T *buf, bool checkall)
|
||||
.append = false,
|
||||
.forceit = false,
|
||||
};
|
||||
bool empty_buf = buf->b_fname == NULL;
|
||||
|
||||
dialog_msg(buff, _("Save changes to \"%s\"?"), buf->b_fname);
|
||||
if (checkall) {
|
||||
@ -213,7 +212,8 @@ void dialog_changed(buf_T *buf, bool checkall)
|
||||
}
|
||||
|
||||
if (ret == VIM_YES) {
|
||||
if (empty_buf) {
|
||||
bool empty_bufname = buf->b_fname == NULL;
|
||||
if (empty_bufname) {
|
||||
buf_set_name(buf->b_fnum, "Untitled");
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ void dialog_changed(buf_T *buf, bool checkall)
|
||||
}
|
||||
|
||||
// restore to empty when write failed
|
||||
if (empty_buf) {
|
||||
if (empty_bufname) {
|
||||
XFREE_CLEAR(buf->b_fname);
|
||||
XFREE_CLEAR(buf->b_ffname);
|
||||
XFREE_CLEAR(buf->b_sfname);
|
||||
|
@ -3921,39 +3921,40 @@ func Test_Changed_ChangedI()
|
||||
\ {'term_rows': 10})
|
||||
call assert_equal('running', term_getstatus(buf))
|
||||
call WaitForAssert({-> assert_true(filereadable('XTextChangedI3'))})
|
||||
defer delete('XTextChangedI3')
|
||||
call WaitForAssert({-> assert_equal([''], readfile('XTextChangedI3'))})
|
||||
|
||||
" TextChanged should trigger if a mapping enters and leaves Insert mode.
|
||||
call term_sendkeys(buf, "\<CR>")
|
||||
call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')[0])})
|
||||
call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')->join("\n"))})
|
||||
|
||||
call term_sendkeys(buf, "i")
|
||||
call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
|
||||
call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')[0])})
|
||||
call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')->join("\n"))})
|
||||
" TextChangedI should trigger if change is done in Insert mode.
|
||||
call term_sendkeys(buf, "f")
|
||||
call WaitForAssert({-> assert_equal('N4,I5', readfile('XTextChangedI3')[0])})
|
||||
call WaitForAssert({-> assert_equal('N4,I5', readfile('XTextChangedI3')->join("\n"))})
|
||||
call term_sendkeys(buf, "o")
|
||||
call WaitForAssert({-> assert_equal('N4,I6', readfile('XTextChangedI3')[0])})
|
||||
call WaitForAssert({-> assert_equal('N4,I6', readfile('XTextChangedI3')->join("\n"))})
|
||||
call term_sendkeys(buf, "o")
|
||||
call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')[0])})
|
||||
call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')->join("\n"))})
|
||||
" TextChanged shouldn't trigger when leaving Insert mode and TextChangedI
|
||||
" has been triggered.
|
||||
call term_sendkeys(buf, "\<Esc>")
|
||||
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
||||
call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')[0])})
|
||||
call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')->join("\n"))})
|
||||
|
||||
" TextChanged should trigger if change is done in Normal mode.
|
||||
call term_sendkeys(buf, "yyp")
|
||||
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')[0])})
|
||||
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))})
|
||||
|
||||
" TextChangedI shouldn't trigger if change isn't done in Insert mode.
|
||||
call term_sendkeys(buf, "i")
|
||||
call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
|
||||
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')[0])})
|
||||
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))})
|
||||
call term_sendkeys(buf, "\<Esc>")
|
||||
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
||||
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')[0])})
|
||||
call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))})
|
||||
|
||||
" TextChangedI should trigger if change is a mix of Normal and Insert modes.
|
||||
func! s:validate_mixed_textchangedi(buf, keys)
|
||||
@ -3963,13 +3964,13 @@ func Test_Changed_ChangedI()
|
||||
call term_sendkeys(buf, "\<Esc>")
|
||||
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
||||
call term_sendkeys(buf, ":let [g:autocmd_n, g:autocmd_i] = ['', '']\<CR>")
|
||||
call delete('XTextChangedI3')
|
||||
call writefile([], 'XTextChangedI3')
|
||||
call term_sendkeys(buf, a:keys)
|
||||
call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
|
||||
call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')[0])})
|
||||
call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')->join("\n"))})
|
||||
call term_sendkeys(buf, "\<Esc>")
|
||||
call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
|
||||
call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')[0])})
|
||||
call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')->join("\n"))})
|
||||
endfunc
|
||||
|
||||
call s:validate_mixed_textchangedi(buf, "o")
|
||||
@ -3982,7 +3983,6 @@ func Test_Changed_ChangedI()
|
||||
|
||||
" clean up
|
||||
bwipe!
|
||||
call delete('XTextChangedI3')
|
||||
endfunc
|
||||
|
||||
" Test that filetype detection still works when SwapExists autocommand sets
|
||||
|
@ -11,8 +11,12 @@ func Test_FileChangedShell_reload()
|
||||
new Xchanged_r
|
||||
call setline(1, 'reload this')
|
||||
write
|
||||
" Need to wait until the timestamp would change by at least a second.
|
||||
sleep 2
|
||||
" Need to wait until the timestamp would change.
|
||||
if has('nanotime')
|
||||
sleep 10m
|
||||
else
|
||||
sleep 2
|
||||
endif
|
||||
silent !echo 'extra line' >>Xchanged_r
|
||||
checktime
|
||||
call assert_equal('changed', g:reason)
|
||||
@ -50,7 +54,11 @@ func Test_FileChangedShell_reload()
|
||||
call assert_equal('new line', getline(1))
|
||||
|
||||
" Only time changed
|
||||
sleep 2
|
||||
if has('nanotime')
|
||||
sleep 10m
|
||||
else
|
||||
sleep 2
|
||||
endif
|
||||
silent !touch Xchanged_r
|
||||
let g:reason = ''
|
||||
checktime
|
||||
@ -65,7 +73,11 @@ func Test_FileChangedShell_reload()
|
||||
call setline(2, 'before write')
|
||||
write
|
||||
call setline(2, 'after write')
|
||||
sleep 2
|
||||
if has('nanotime')
|
||||
sleep 10m
|
||||
else
|
||||
sleep 2
|
||||
endif
|
||||
silent !echo 'different line' >>Xchanged_r
|
||||
let g:reason = ''
|
||||
checktime
|
||||
@ -198,8 +210,12 @@ func Test_file_changed_dialog()
|
||||
new Xchanged_d
|
||||
call setline(1, 'reload this')
|
||||
write
|
||||
" Need to wait until the timestamp would change by at least a second.
|
||||
sleep 2
|
||||
" Need to wait until the timestamp would change.
|
||||
if has('nanotime')
|
||||
sleep 10m
|
||||
else
|
||||
sleep 2
|
||||
endif
|
||||
silent !echo 'extra line' >>Xchanged_d
|
||||
call feedkeys('L', 'L')
|
||||
checktime
|
||||
@ -234,7 +250,11 @@ func Test_file_changed_dialog()
|
||||
call assert_equal('new line', getline(1))
|
||||
|
||||
" Only time changed, no prompt
|
||||
sleep 2
|
||||
if has('nanotime')
|
||||
sleep 10m
|
||||
else
|
||||
sleep 2
|
||||
endif
|
||||
silent !touch Xchanged_d
|
||||
let v:warningmsg = ''
|
||||
checktime Xchanged_d
|
||||
|
Loading…
Reference in New Issue
Block a user