From 83cad98d5d4272adfc97f7c2cab0673b7d29a0a0 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Mon, 30 Jun 2014 19:03:46 -0300 Subject: api: make buffer_{get,set}_slice automatically assume `include_end` This is for compatibility with python-vim interface: When passing an end index with a value higher than the last index, assume the `include_end` flag --- src/nvim/api/buffer.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/api/buffer.c') diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 9c58baca39..21bfc5ede0 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -109,6 +109,7 @@ StringArray buffer_get_slice(Buffer buffer, } start = normalize_index(buf, start) + (include_start ? 0 : 1); + include_end = include_end || (end >= buf->b_ml.ml_line_count); end = normalize_index(buf, end) + (include_end ? 1 : 0); if (start >= end) { @@ -169,6 +170,7 @@ void buffer_set_slice(Buffer buffer, } start = normalize_index(buf, start) + (include_start ? 0 : 1); + include_end = include_end || (end >= buf->b_ml.ml_line_count); end = normalize_index(buf, end) + (include_end ? 1 : 0); if (start > end) { -- cgit