aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/buffer.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2018-11-02 08:36:38 +0100
committerGitHub <noreply@github.com>2018-11-02 08:36:38 +0100
commit48398d61e422f74db4fa5c2e279692dd97347f41 (patch)
treeef7e2f51195c6a5a1a5f7a210290b43868c4d3c8 /src/nvim/api/buffer.c
parentc45a859171090746c8b81f183474c22e489b8ad0 (diff)
parentc40f992e10355edd586d5cfbca246b9659554438 (diff)
downloadrneovim-48398d61e422f74db4fa5c2e279692dd97347f41.tar.gz
rneovim-48398d61e422f74db4fa5c2e279692dd97347f41.tar.bz2
rneovim-48398d61e422f74db4fa5c2e279692dd97347f41.zip
Merge pull request #9183 from bfredl/offset2
api: make nvim_buf_get_offset independent on platform option
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r--src/nvim/api/buffer.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 9866f1140e..39330690e8 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -493,11 +493,10 @@ end:
/// Return the byte offset for a line.
//
-/// This includes the end-of-line character, depending on the 'fileformat'
-/// option for the current buffer. The first line returns 0. UTF-8 encoding is
-/// used, 'fileencoding' is ignored. Sending in the index just below the last
-/// line gives the total byte count for the entire file. A final newline is
-/// included if it would be written, see 'eol'.
+/// The first line returns 0. UTF-8 bytes are counted, and EOL counts as one
+/// byte. 'fileformat' and 'fileencoding' are ignored. Sending in the index
+/// just below the last line gives the total byte count for the entire buffer.
+/// A final EOL is included if it would be written, see 'eol'.
///
/// Unlike |line2byte()|, throws error for out-of-bounds indexing.
/// Returns -1 for unloaded buffer.
@@ -506,7 +505,7 @@ end:
/// @param index Line index
/// @param[out] err Error details, if any
/// @return Integer Byte offset
-Integer nvim_buf_get_offset_for_line(Buffer buffer, Integer index, Error *err)
+Integer nvim_buf_get_offset(Buffer buffer, Integer index, Error *err)
FUNC_API_SINCE(5)
{
buf_T *buf = find_buffer_by_handle(buffer, err);
@@ -524,7 +523,7 @@ Integer nvim_buf_get_offset_for_line(Buffer buffer, Integer index, Error *err)
return 0;
}
- return ml_find_line_or_offset(buf, (int)index+1, NULL);
+ return ml_find_line_or_offset(buf, (int)index+1, NULL, true);
}
/// Gets a buffer-scoped (b:) variable.