diff options
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r-- | src/nvim/buffer.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 7ea5a64a96..0ebe33f2f8 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -5416,7 +5416,7 @@ char_u *buf_spname(buf_T *buf) return (char_u *)_("[Scratch]"); } if (buf->b_fname == NULL) { - return (char_u *)_("[No Name]"); + return buf_get_fname(buf); } return NULL; } @@ -5477,6 +5477,16 @@ int buf_signcols(buf_T *buf) return buf->b_signcols; } +// Get "buf->b_fname", use "[No Name]" if it is NULL. +char_u *buf_get_fname(const buf_T *buf) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL +{ + if (buf->b_fname == NULL) { + return (char_u *)_("[No Name]"); + } + return buf->b_fname; +} + /* * Set 'buflisted' for curbuf to "on" and trigger autocommands if it changed. */ |