aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-06-12 20:26:04 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-06-18 18:01:43 -0400
commit3c9ec83395b4419e7030d35b5a92b6d008ca25ea (patch)
treea30e4254f8e1b1f1026d05fe96451b6c848c3904 /src
parentabadb687fb76b9ef34c5df7f6da88fdf0a20577b (diff)
downloadrneovim-3c9ec83395b4419e7030d35b5a92b6d008ca25ea.tar.gz
rneovim-3c9ec83395b4419e7030d35b5a92b6d008ca25ea.tar.bz2
rneovim-3c9ec83395b4419e7030d35b5a92b6d008ca25ea.zip
vim-patch:8.2.0966: 'shortmess' flag "n" not used in two places
Problem: 'shortmess' flag "n" not used in two places. Solution: Make use of the "n" flag consistent. (Nick Jensen, closes vim/vim#6245, closes vim/vim#6244) https://github.com/vim/vim/commit/722e505d1a55dfde5ab62241d10da91d2e10c3c1
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c37
-rw-r--r--src/nvim/fileio.c32
2 files changed, 38 insertions, 31 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 3ce39feda5..29712e9f52 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -3084,28 +3084,29 @@ fileinfo(
}
vim_snprintf_add((char *)buffer, IOSIZE, "\"%s%s%s%s%s%s",
- curbufIsChanged() ? (shortmess(SHM_MOD)
- ? " [+]" : _(" [Modified]")) : " ",
- (curbuf->b_flags & BF_NOTEDITED)
- && !bt_dontwrite(curbuf)
- ? _("[Not edited]") : "",
- (curbuf->b_flags & BF_NEW)
- && !bt_dontwrite(curbuf)
- ? _("[New file]") : "",
- (curbuf->b_flags & BF_READERR) ? _("[Read errors]") : "",
- curbuf->b_p_ro ? (shortmess(SHM_RO) ? _("[RO]")
- : _("[readonly]")) : "",
- (curbufIsChanged() || (curbuf->b_flags & BF_WRITE_MASK)
- || curbuf->b_p_ro) ?
- " " : "");
- /* With 32 bit longs and more than 21,474,836 lines multiplying by 100
- * causes an overflow, thus for large numbers divide instead. */
- if (curwin->w_cursor.lnum > 1000000L)
+ curbufIsChanged()
+ ? (shortmess(SHM_MOD) ? " [+]" : _(" [Modified]")) : " ",
+ (curbuf->b_flags & BF_NOTEDITED) && !bt_dontwrite(curbuf)
+ ? _("[Not edited]") : "",
+ (curbuf->b_flags & BF_NEW) && !bt_dontwrite(curbuf)
+ ? new_file_message() : "",
+ (curbuf->b_flags & BF_READERR)
+ ? _("[Read errors]") : "",
+ curbuf->b_p_ro
+ ? (shortmess(SHM_RO) ? _("[RO]") : _("[readonly]")) : "",
+ (curbufIsChanged()
+ || (curbuf->b_flags & BF_WRITE_MASK)
+ || curbuf->b_p_ro)
+ ? " " : "");
+ // With 32 bit longs and more than 21,474,836 lines multiplying by 100
+ // causes an overflow, thus for large numbers divide instead.
+ if (curwin->w_cursor.lnum > 1000000L) {
n = (int)(((long)curwin->w_cursor.lnum) /
((long)curbuf->b_ml.ml_line_count / 100L));
- else
+ } else {
n = (int)(((long)curwin->w_cursor.lnum * 100L) /
(long)curbuf->b_ml.ml_line_count);
+ }
if (curbuf->b_ml.ml_flags & ML_EMPTY) {
vim_snprintf_add((char *)buffer, IOSIZE, "%s", _(no_lines_msg));
} else if (p_ru) {
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index f29304867a..20f0cdccc3 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -569,20 +569,21 @@ readfile(
return FAIL;
}
}
- if (dir_of_file_exists(fname))
- filemess(curbuf, sfname, (char_u *)_("[New File]"), 0);
- else
- filemess(curbuf, sfname,
- (char_u *)_("[New DIRECTORY]"), 0);
- /* Even though this is a new file, it might have been
- * edited before and deleted. Get the old marks. */
+ if (dir_of_file_exists(fname)) {
+ filemess(curbuf, sfname, (char_u *)new_file_message(), 0);
+ } else {
+ filemess(curbuf, sfname, (char_u *)_("[New DIRECTORY]"), 0);
+ }
+ // Even though this is a new file, it might have been
+ // edited before and deleted. Get the old marks.
check_marks_read();
- /* Set forced 'fileencoding'. */
- if (eap != NULL)
+ // Set forced 'fileencoding'.
+ if (eap != NULL) {
set_forced_fenc(eap);
+ }
apply_autocmds_exarg(EVENT_BUFNEWFILE, sfname, sfname,
- FALSE, curbuf, eap);
- /* remember the current fileformat */
+ false, curbuf, eap);
+ // remember the current fileformat
save_file_ff(curbuf);
if (aborting()) /* autocmds may abort script processing */
@@ -2203,6 +2204,11 @@ static void check_marks_read(void)
curbuf->b_marks_read = true;
}
+char *new_file_message(void)
+{
+ return shortmess(SHM_NEW) ? _("[New]") : _("[New File]");
+}
+
/*
* buf_write() - write to file "fname" lines "start" through "end"
*
@@ -3513,8 +3519,8 @@ restore_backup:
STRCAT(IObuff, _("[Device]"));
c = TRUE;
} else if (newfile) {
- STRCAT(IObuff, shortmess(SHM_NEW) ? _("[New]") : _("[New File]"));
- c = TRUE;
+ STRCAT(IObuff, new_file_message());
+ c = true;
}
if (no_eol) {
msg_add_eol();