Merge #7530 'vim-patch:8.0.0226 vim-patch:8.0.0224'

This commit is contained in:
Justin M. Keyes
2017-11-13 01:26:22 +01:00
3 changed files with 51 additions and 29 deletions

View File

@@ -302,12 +302,9 @@ readfile (
linenr_T skip_count = 0; linenr_T skip_count = 0;
linenr_T read_count = 0; linenr_T read_count = 0;
int msg_save = msg_scroll; int msg_save = msg_scroll;
linenr_T read_no_eol_lnum = 0; /* non-zero lnum when last line of linenr_T read_no_eol_lnum = 0; // non-zero lnum when last line of
* last read was missing the eol */ // last read was missing the eol
int try_mac = (vim_strchr(p_ffs, 'm') != NULL); int file_rewind = false;
int try_dos = (vim_strchr(p_ffs, 'd') != NULL);
int try_unix = (vim_strchr(p_ffs, 'x') != NULL);
int file_rewind = FALSE;
int can_retry; int can_retry;
linenr_T conv_error = 0; /* line nr with conversion error */ linenr_T conv_error = 0; /* line nr with conversion error */
linenr_T illegal_byte = 0; /* line nr with illegal byte */ linenr_T illegal_byte = 0; /* line nr with illegal byte */
@@ -639,37 +636,46 @@ readfile (
curbuf->b_op_start.lnum = ((from == 0) ? 1 : from); curbuf->b_op_start.lnum = ((from == 0) ? 1 : from);
curbuf->b_op_start.col = 0; curbuf->b_op_start.col = 0;
int try_mac = (vim_strchr(p_ffs, 'm') != NULL);
int try_dos = (vim_strchr(p_ffs, 'd') != NULL);
int try_unix = (vim_strchr(p_ffs, 'x') != NULL);
if (!read_buffer) { if (!read_buffer) {
int m = msg_scroll; int m = msg_scroll;
int n = msg_scrolled; int n = msg_scrolled;
/* // The file must be closed again, the autocommands may want to change
* The file must be closed again, the autocommands may want to change // the file before reading it.
* the file before reading it. if (!read_stdin) {
*/ close(fd); // ignore errors
if (!read_stdin) }
close(fd); /* ignore errors */
/* // The output from the autocommands should not overwrite anything and
* The output from the autocommands should not overwrite anything and // should not be overwritten: Set msg_scroll, restore its value if no
* should not be overwritten: Set msg_scroll, restore its value if no // output was done.
* output was done. msg_scroll = true;
*/ if (filtering) {
msg_scroll = TRUE;
if (filtering)
apply_autocmds_exarg(EVENT_FILTERREADPRE, NULL, sfname, apply_autocmds_exarg(EVENT_FILTERREADPRE, NULL, sfname,
FALSE, curbuf, eap); false, curbuf, eap);
else if (read_stdin) } else if (read_stdin) {
apply_autocmds_exarg(EVENT_STDINREADPRE, NULL, sfname, apply_autocmds_exarg(EVENT_STDINREADPRE, NULL, sfname,
FALSE, curbuf, eap); false, curbuf, eap);
else if (newfile) } else if (newfile) {
apply_autocmds_exarg(EVENT_BUFREADPRE, NULL, sfname, apply_autocmds_exarg(EVENT_BUFREADPRE, NULL, sfname,
FALSE, curbuf, eap); false, curbuf, eap);
else } else {
apply_autocmds_exarg(EVENT_FILEREADPRE, sfname, sfname, apply_autocmds_exarg(EVENT_FILEREADPRE, sfname, sfname,
FALSE, NULL, eap); false, NULL, eap);
if (msg_scrolled == n) }
// autocommands may have changed it
try_mac = (vim_strchr(p_ffs, 'm') != NULL);
try_dos = (vim_strchr(p_ffs, 'd') != NULL);
try_unix = (vim_strchr(p_ffs, 'x') != NULL);
if (msg_scrolled == n) {
msg_scroll = m; msg_scroll = m;
}
if (aborting()) { /* autocmds may abort script processing */ if (aborting()) { /* autocmds may abort script processing */
--no_wait_return; --no_wait_return;

View File

@@ -15,3 +15,19 @@ func Test_fileformat_after_bw()
call assert_equal(test_fileformats, &fileformat) call assert_equal(test_fileformats, &fileformat)
set fileformats& set fileformats&
endfunc endfunc
func Test_fileformat_autocommand()
let filecnt = ["\<CR>", "foobar\<CR>", "eins\<CR>", "\<CR>", "zwei\<CR>", "drei", "vier", "fünf", ""]
let ffs = &ffs
call writefile(filecnt, 'Xfile', 'b')
au BufReadPre Xfile set ffs=dos ff=dos
new Xfile
call assert_equal('dos', &l:ff)
call assert_equal('dos', &ffs)
" cleanup
call delete('Xfile')
let &ffs = ffs
au! BufReadPre Xfile
bw!
endfunc

View File

@@ -878,9 +878,9 @@ static const int included_patches[] = {
229, 229,
// 228, // 228,
// 227, // 227,
// 226, 226,
// 225, // 225,
// 224, 224,
223, 223,
// 222, // 222,
// 221 NA // 221 NA