diff options
author | Peter Hodge <peter.hodge84@gmail.com> | 2018-06-29 11:44:08 +1000 |
---|---|---|
committer | Peter Hodge <peter.hodge84@gmail.com> | 2018-07-25 15:07:13 +1000 |
commit | 8ff0872cf75c331680748c23329cc42d4db8fee1 (patch) | |
tree | c7fcf34eaa3f2272847a5d48b36ae4a1fb58fbc6 /src/nvim/api/buffer.c | |
parent | 40e2d6b59becc0e252966f81a0583f44459d1451 (diff) | |
download | rneovim-8ff0872cf75c331680748c23329cc42d4db8fee1.tar.gz rneovim-8ff0872cf75c331680748c23329cc42d4db8fee1.tar.bz2 rneovim-8ff0872cf75c331680748c23329cc42d4db8fee1.zip |
API: add nvim_buf_is_loaded() #7688
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r-- | src/nvim/api/buffer.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 3acebd6df3..206c32073b 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -755,6 +755,19 @@ void nvim_buf_set_name(Buffer buffer, String name, Error *err) } } +/// Checks if a buffer is valid and loaded +/// +/// @param buffer Buffer handle +/// @return true if the buffer is valid and loaded, false otherwise +Boolean nvim_buf_is_loaded(Buffer buffer) + FUNC_API_SINCE(5) +{ + Error stub = ERROR_INIT; + buf_T *buf = find_buffer_by_handle(buffer, &stub); + api_clear_error(&stub); + return buf && buf->b_ml.ml_mfp != NULL; +} + /// Checks if a buffer is valid /// /// @param buffer Buffer handle |