The counted number of bytes is decreased if 'bin' and 'noeol' are set.
This is incorrect, and the logic should only apply when the requested
line is the last line in the buffer.
Test cases:
vim -b <(printf '123\n567') +':echo line2byte(1)'
Expected: 1
Actual : -1
vim -b <(printf '123\n567') +':echo line2byte(2)'
Expected: 5
Actual : 4
vim -b <(printf '123\r\n678') +':echo line2byte(2)'
Expected: 6
Actual : 5
vim -b <(printf '123\n567') +':echo line2byte(3)'
Expected: 9
Actual : 8
vim -b <(printf '123\r\n678') +':echo line2byte(3)'
Expected: 10 (not 11, because in binary mode fileformat is ignored,
so pressing enter adds a LF and not a CR LF).
Actual : 9
---
src/memline.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/memline.c b/src/memline.c
index e809360..91ef270 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -5362,7 +5362,7 @@ ml_find_line_or_offset(buf, lnum, offp)
size += lnum - 1;
/* Don't count the last line break if 'bin' and 'noeol'. */
- if (buf->b_p_bin && !buf->b_p_eol)
+ if (buf->b_p_bin && !buf->b_p_eol && buf->b_ml.ml_line_count == lnum)
size -= ffdos + 1;
}
--
2.4.5
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.