diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-07-09 10:15:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-09 10:15:18 +0200 |
commit | 1c416892879de6b78038f2cc2f1487eff46abb60 (patch) | |
tree | 3895521bc907b7a0617940c21272ac7ee9f052da /src/nvim/buffer.h | |
parent | 27118c6eb3351b0df96e2514e8f3806108e50cf7 (diff) | |
parent | 9c93e6461c8c6ec2e8d3e73f506389ac7086d531 (diff) | |
download | rneovim-1c416892879de6b78038f2cc2f1487eff46abb60.tar.gz rneovim-1c416892879de6b78038f2cc2f1487eff46abb60.tar.bz2 rneovim-1c416892879de6b78038f2cc2f1487eff46abb60.zip |
Merge pull request #12971 from vigoux/decurbuf
Decrease reliance on curbuf in BUFEMPTY and `undo.c`
Diffstat (limited to 'src/nvim/buffer.h')
-rw-r--r-- | src/nvim/buffer.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index ac7ead5f92..02a2ac36f7 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -9,6 +9,7 @@ #include "nvim/func_attr.h" #include "nvim/eval.h" #include "nvim/macros.h" +#include "nvim/memline.h" // Values for buflist_getfile() enum getf_values { @@ -128,4 +129,10 @@ static inline void buf_inc_changedtick(buf_T *const buf) buf_set_changedtick(buf, buf_get_changedtick(buf) + 1); } +static inline bool buf_is_empty(buf_T *buf) +{ + return buf->b_ml.ml_line_count == 1 + && *ml_get_buf(buf, (linenr_T)1, false) == '\0'; +} + #endif // NVIM_BUFFER_H |