aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-12-12 11:57:56 +0100
committerGitHub <noreply@github.com>2023-12-12 11:57:56 +0100
commite69834744ba550100778890d0b4ecfc3c469af15 (patch)
tree395eed558c5abec6887c06866143618d6a6ffaf2
parent2d33a766a17b7304686fc00eec2b2e0ce49400ba (diff)
parentd95e3a4c9c8f468158a1f1f23921ebbaae75cf8b (diff)
downloadrneovim-e69834744ba550100778890d0b4ecfc3c469af15.tar.gz
rneovim-e69834744ba550100778890d0b4ecfc3c469af15.tar.bz2
rneovim-e69834744ba550100778890d0b4ecfc3c469af15.zip
Merge pull request #26486 from glepnir/fix_linebyte
fix(eval): use no_ff instead of ffdos as condition
-rw-r--r--src/nvim/memline.c2
-rw-r--r--test/functional/api/buffer_spec.lua1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 9dc2d929b2..38ac3b7bcf 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -3907,7 +3907,7 @@ int ml_find_line_or_offset(buf_T *buf, linenr_T lnum, int *offp, bool no_ff)
|| lnum < 0) {
// memline is currently empty. Although if it is loaded,
// it behaves like there is one empty line.
- if (!ffdos && buf->b_ml.ml_mfp && (lnum == 1 || lnum == 2)) {
+ if (no_ff && buf->b_ml.ml_mfp && (lnum == 1 || lnum == 2)) {
return lnum - 1;
}
return -1;
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua
index db910545ef..b618bf0e6c 100644
--- a/test/functional/api/buffer_spec.lua
+++ b/test/functional/api/buffer_spec.lua
@@ -1834,6 +1834,7 @@ describe('api/buf', function()
it('works in empty buffer', function()
eq(0, get_offset(0))
eq(1, get_offset(1))
+ eq(-1, funcs.line2byte('$'))
end)
it('works in buffer with one line inserted', function()