aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-04-06 06:18:50 +0800
committerGitHub <noreply@github.com>2024-04-06 06:18:50 +0800
commita4e4e493df5f6897345278a460cccd175f7f4cf0 (patch)
tree3756b635dd15bd1feec4c710896f76673def8e81
parent66568ed4521972cd34d9f635511b979481e2dc01 (diff)
parentc7d12a5e0110d3dcaa866c157d12fd33a6bed95b (diff)
downloadrneovim-a4e4e493df5f6897345278a460cccd175f7f4cf0.tar.gz
rneovim-a4e4e493df5f6897345278a460cccd175f7f4cf0.tar.bz2
rneovim-a4e4e493df5f6897345278a460cccd175f7f4cf0.zip
Merge pull request #28194 from zeertzjq/vim-9.1.0267
vim-patch:9.1.{0267,0268,0269}
-rw-r--r--src/nvim/ex_cmds2.c6
-rw-r--r--test/old/testdir/test_autocmd.vim26
-rw-r--r--test/old/testdir/test_filechanged.vim34
3 files changed, 43 insertions, 23 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 898c3fb3f9..b7f4f269e1 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -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);
diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim
index 254a67fac4..c1bbc8a129 100644
--- a/test/old/testdir/test_autocmd.vim
+++ b/test/old/testdir/test_autocmd.vim
@@ -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
diff --git a/test/old/testdir/test_filechanged.vim b/test/old/testdir/test_filechanged.vim
index b9f8d4c37a..a8fc78ff90 100644
--- a/test/old/testdir/test_filechanged.vim
+++ b/test/old/testdir/test_filechanged.vim
@@ -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