diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 7 | ||||
-rw-r--r-- | src/nvim/fileio.c | 60 | ||||
-rw-r--r-- | src/nvim/screen.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_fileformat.vim | 16 | ||||
-rw-r--r-- | src/nvim/version.c | 8 | ||||
-rw-r--r-- | src/nvim/window.c | 18 |
6 files changed, 57 insertions, 56 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index f874268910..766003a021 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -64,7 +64,6 @@ #include "nvim/spell.h" #include "nvim/strings.h" #include "nvim/syntax.h" -#include "nvim/terminal.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/version.h" @@ -1464,12 +1463,6 @@ void enter_buffer(buf_T *buf) /* mark cursor position as being invalid */ curwin->w_valid = 0; - if (buf->terminal) { - terminal_resize(buf->terminal, - (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), - (uint16_t)curwin->w_height); - } - /* Make sure the buffer is loaded. */ if (curbuf->b_ml.ml_mfp == NULL) { /* need to load the file */ /* If there is no filetype, allow for detecting one. Esp. useful for diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index feb16f44d4..a7676e88f0 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -302,12 +302,9 @@ readfile ( linenr_T skip_count = 0; linenr_T read_count = 0; int msg_save = msg_scroll; - linenr_T read_no_eol_lnum = 0; /* non-zero lnum when last line of - * last read was missing the eol */ - 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); - int file_rewind = FALSE; + linenr_T read_no_eol_lnum = 0; // non-zero lnum when last line of + // last read was missing the eol + int file_rewind = false; int can_retry; linenr_T conv_error = 0; /* line nr with conversion error */ 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.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) { int m = msg_scroll; int n = msg_scrolled; - /* - * The file must be closed again, the autocommands may want to change - * the file before reading it. - */ - if (!read_stdin) - close(fd); /* ignore errors */ + // The file must be closed again, the autocommands may want to change + // the file before reading it. + if (!read_stdin) { + close(fd); // ignore errors + } - /* - * The output from the autocommands should not overwrite anything and - * should not be overwritten: Set msg_scroll, restore its value if no - * output was done. - */ - msg_scroll = TRUE; - if (filtering) + // The output from the autocommands should not overwrite anything and + // should not be overwritten: Set msg_scroll, restore its value if no + // output was done. + msg_scroll = true; + if (filtering) { apply_autocmds_exarg(EVENT_FILTERREADPRE, NULL, sfname, - FALSE, curbuf, eap); - else if (read_stdin) + false, curbuf, eap); + } else if (read_stdin) { apply_autocmds_exarg(EVENT_STDINREADPRE, NULL, sfname, - FALSE, curbuf, eap); - else if (newfile) + false, curbuf, eap); + } else if (newfile) { apply_autocmds_exarg(EVENT_BUFREADPRE, NULL, sfname, - FALSE, curbuf, eap); - else + false, curbuf, eap); + } else { apply_autocmds_exarg(EVENT_FILEREADPRE, sfname, sfname, - FALSE, NULL, eap); - if (msg_scrolled == n) + false, NULL, eap); + } + + // 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; + } if (aborting()) { /* autocmds may abort script processing */ --no_wait_return; diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 41e900eb4c..ed96e98d32 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -696,8 +696,8 @@ static void win_update(win_T *wp) if (buf->terminal) { terminal_resize(buf->terminal, - (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), - (uint16_t)curwin->w_height); + (uint16_t)(MAX(0, wp->w_width - win_col_off(wp))), + (uint16_t)wp->w_height); } } else if (buf->b_mod_set && buf->b_mod_xlines != 0 diff --git a/src/nvim/testdir/test_fileformat.vim b/src/nvim/testdir/test_fileformat.vim index 584f20cdfc..de505d3bd0 100644 --- a/src/nvim/testdir/test_fileformat.vim +++ b/src/nvim/testdir/test_fileformat.vim @@ -15,3 +15,19 @@ func Test_fileformat_after_bw() call assert_equal(test_fileformats, &fileformat) set fileformats& 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 diff --git a/src/nvim/version.c b/src/nvim/version.c index 05725a59f9..5accf8f1d6 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -856,10 +856,10 @@ static const int included_patches[] = { // 251, 250, // 249 NA - // 248, + // 248 NA 247, // 246 NA - // 245, + 245, // 244, 243, 242, @@ -878,9 +878,9 @@ static const int included_patches[] = { 229, // 228, // 227, - // 226, + 226, // 225, - // 224, + 224, 223, // 222, // 221 NA diff --git a/src/nvim/window.c b/src/nvim/window.c index 2d64409a1c..4e4eb297aa 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1846,12 +1846,6 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, shell_new_rows(); } - if (term) { - // When a window containing a terminal buffer is closed, recalculate its - // size - terminal_resize(term, 0, 0); - } - // Since goto_tabpage_tp above did not trigger *Enter autocommands, do // that now. apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, curbuf); @@ -3745,12 +3739,6 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, /* Change directories when the 'acd' option is set. */ do_autochdir(); - - if (curbuf->terminal) { - terminal_resize(curbuf->terminal, - (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), - (uint16_t)curwin->w_height); - } } @@ -4930,9 +4918,7 @@ void scroll_to_fraction(win_T *wp, int prev_height) } } -/* - * Set the width of a window. - */ +/// Set the width of a window. void win_new_width(win_T *wp, int width) { wp->w_width = width; @@ -4949,7 +4935,7 @@ void win_new_width(win_T *wp, int width) if (wp->w_buffer->terminal) { if (wp->w_height != 0) { terminal_resize(wp->w_buffer->terminal, - (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), + (uint16_t)(MAX(0, wp->w_width - win_col_off(wp))), 0); } } |