This commit is contained in:
Justin M. Keyes
2017-01-12 16:40:28 +01:00
parent 42c922b32c
commit b5e8e2f20d
3 changed files with 31 additions and 30 deletions

View File

@@ -189,15 +189,16 @@ open_buffer (
curwin->w_cursor.lnum = 1; curwin->w_cursor.lnum = 1;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
/* Set or reset 'modified' before executing autocommands, so that // Set or reset 'modified' before executing autocommands, so that
* it can be changed there. */ // it can be changed there.
if (!readonlymode && !bufempty()) if (!readonlymode && !bufempty()) {
changed(); changed();
else if (retval == OK) { } else if (retval == OK) {
unchanged(curbuf, FALSE); unchanged(curbuf, false);
} }
if (retval == OK) { if (retval == OK) {
apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE, apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, false,
curbuf, &retval); curbuf, &retval);
} }
} }
@@ -209,22 +210,21 @@ open_buffer (
parse_cino(curbuf); parse_cino(curbuf);
} }
/* // Set/reset the Changed flag first, autocmds may change the buffer.
* Set/reset the Changed flag first, autocmds may change the buffer. // Apply the automatic commands, before processing the modelines.
* Apply the automatic commands, before processing the modelines. // So the modelines have priority over auto commands.
* So the modelines have priority over auto commands.
*/ // When reading stdin, the buffer contents always needs writing, so set
/* When reading stdin, the buffer contents always needs writing, so set // the changed flag. Unless in readonly mode: "ls | nvim -R -".
* the changed flag. Unless in readonly mode: "ls | nvim -R -". // When interrupted and 'cpoptions' contains 'i' set changed flag.
* When interrupted and 'cpoptions' contains 'i' set changed flag. */
if ((got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL) if ((got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
|| modified_was_set /* ":set modified" used in autocmd */ || modified_was_set // ":set modified" used in autocmd
|| (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL) || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL)) {
)
changed(); changed();
else if (retval == OK && !read_stdin) } else if (retval == OK && !read_stdin) {
unchanged(curbuf, FALSE); unchanged(curbuf, false);
save_file_ff(curbuf); /* keep this fileformat */ }
save_file_ff(curbuf); // keep this fileformat
/* require "!" to overwrite the file, because it wasn't read completely */ /* require "!" to overwrite the file, because it wasn't read completely */
if (aborting()) if (aborting())

View File

@@ -5105,13 +5105,13 @@ void buf_reload(buf_T *buf, int orig_mode)
} }
if (saved == OK) { if (saved == OK) {
curbuf->b_flags |= BF_CHECK_RO; /* check for RO again */ curbuf->b_flags |= BF_CHECK_RO; // check for RO again
keep_filetype = TRUE; /* don't detect 'filetype' */ keep_filetype = true; // don't detect 'filetype'
if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0, if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0,
(linenr_T)0, (linenr_T)MAXLNUM, &ea, flags) != OK) {
(linenr_T)MAXLNUM, &ea, flags) != OK) { if (!aborting()) {
if (!aborting())
EMSG2(_("E321: Could not reload \"%s\""), buf->b_fname); EMSG2(_("E321: Could not reload \"%s\""), buf->b_fname);
}
if (savebuf != NULL && buf_valid(savebuf) && buf == curbuf) { if (savebuf != NULL && buf_valid(savebuf) && buf == curbuf) {
/* Put the text back from the save buffer. First /* Put the text back from the save buffer. First
* delete any lines that readfile() added. */ * delete any lines that readfile() added. */

View File

@@ -1063,11 +1063,12 @@ void ml_recover(void)
if (!cannot_open) { if (!cannot_open) {
line_count = pp->pb_pointer[idx].pe_line_count; line_count = pp->pb_pointer[idx].pe_line_count;
if (readfile(curbuf->b_ffname, NULL, lnum, if (readfile(curbuf->b_ffname, NULL, lnum,
pp->pb_pointer[idx].pe_old_lnum - 1, pp->pb_pointer[idx].pe_old_lnum - 1, line_count,
line_count, NULL, 0) != OK) NULL, 0) != OK) {
cannot_open = TRUE; cannot_open = true;
else } else {
lnum += line_count; lnum += line_count;
}
} }
if (cannot_open) { if (cannot_open) {
++error; ++error;