diff options
author | Peter Hodge <peter.hodge84@gmail.com> | 2018-06-29 11:43:37 +1000 |
---|---|---|
committer | Peter Hodge <peter.hodge84@gmail.com> | 2018-07-25 15:07:13 +1000 |
commit | 40e2d6b59becc0e252966f81a0583f44459d1451 (patch) | |
tree | a3ba9e88df619991b04c9e077a8402a0aba7fcc0 /src/nvim/api/buffer.c | |
parent | ae52170a52150fc5678d2c03bb52df9943e89ee1 (diff) | |
download | rneovim-40e2d6b59becc0e252966f81a0583f44459d1451.tar.gz rneovim-40e2d6b59becc0e252966f81a0583f44459d1451.tar.bz2 rneovim-40e2d6b59becc0e252966f81a0583f44459d1451.zip |
API: buf_get_lines, buf_line_count handle unloaded buffers #7688
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r-- | src/nvim/api/buffer.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 8ff24b877e..3acebd6df3 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -45,6 +45,11 @@ Integer nvim_buf_line_count(Buffer buffer, Error *err) return 0; } + // return sentinel value if the buffer isn't loaded + if (buf->b_ml.ml_mfp == NULL) { + return 0; + } + return buf->b_ml.ml_line_count; } @@ -221,6 +226,11 @@ ArrayOf(String) nvim_buf_get_lines(uint64_t channel_id, return rv; } + // return sentinel value if the buffer isn't loaded + if (buf->b_ml.ml_mfp == NULL) { + return rv; + } + bool oob = false; start = normalize_index(buf, start, &oob); end = normalize_index(buf, end, &oob); |