Mercurial > vim
comparison src/testdir/test_autocmd.vim @ 19836:c32b295af9c5 v8.2.0474
patch 8.2.0474: cannot use :write when using a plugin with BufWriteCmd
Commit: https://github.com/vim/vim/commit/0fff44152d06e6b662ad4bef172af07a041d2f3f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 29 16:06:29 2020 +0200
patch 8.2.0474: cannot use :write when using a plugin with BufWriteCmd
Problem: Cannot use :write when using a plugin with BufWriteCmd.
Solution: Reset BF_NOTEDITED after BufWriteCmd. (closes https://github.com/vim/vim/issues/5807)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 29 Mar 2020 16:15:03 +0200 |
parents | 0927df746554 |
children | 2c4d9ca33769 |
comparison
equal
deleted
inserted
replaced
19835:b56266f40a71 | 19836:c32b295af9c5 |
---|---|
1532 au! FileWriteCmd | 1532 au! FileWriteCmd |
1533 au! FileAppendCmd | 1533 au! FileAppendCmd |
1534 %bwipe! | 1534 %bwipe! |
1535 call delete('Xxx') | 1535 call delete('Xxx') |
1536 enew! | 1536 enew! |
1537 endfunc | |
1538 | |
1539 func s:ReadFile() | |
1540 setl noswapfile nomodified | |
1541 let filename = resolve(expand("<afile>:p")) | |
1542 execute 'read' fnameescape(filename) | |
1543 1d_ | |
1544 exe 'file' fnameescape(filename) | |
1545 setl buftype=acwrite | |
1546 endfunc | |
1547 | |
1548 func s:WriteFile() | |
1549 let filename = resolve(expand("<afile>:p")) | |
1550 setl buftype= | |
1551 noautocmd execute 'write' fnameescape(filename) | |
1552 setl buftype=acwrite | |
1553 setl nomodified | |
1554 endfunc | |
1555 | |
1556 func Test_BufReadCmd() | |
1557 autocmd BufReadCmd *.test call s:ReadFile() | |
1558 autocmd BufWriteCmd *.test call s:WriteFile() | |
1559 | |
1560 call writefile(['one', 'two', 'three'], 'Xcmd.test') | |
1561 edit Xcmd.test | |
1562 call assert_match('Xcmd.test" line 1 of 3', execute('file')) | |
1563 normal! Gofour | |
1564 write | |
1565 call assert_equal(['one', 'two', 'three', 'four'], readfile('Xcmd.test')) | |
1566 | |
1567 bwipe! | |
1568 call delete('Xcmd.test') | |
1569 au! BufReadCmd | |
1570 au! BufWriteCmd | |
1537 endfunc | 1571 endfunc |
1538 | 1572 |
1539 func SetChangeMarks(start, end) | 1573 func SetChangeMarks(start, end) |
1540 exe a:start. 'mark [' | 1574 exe a:start. 'mark [' |
1541 exe a:end. 'mark ]' | 1575 exe a:end. 'mark ]' |