From 26641c0c56148ca9c6726a202527be625b1eec46 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 29 Nov 2025 15:06:13 -0500 Subject: [PATCH] vim-patch:9.0.0010: returning 0 for has('patch-9.0.0') is inconsistent Problem: Returning 0 for has('patch-9.0.0') is inconsistent. Solution: Make it return 1. (closes vim/vim#10640) https://github.com/vim/vim/commit/b0375d466e5ca57dca71995c342870b3226d8115 Co-authored-by: Bram Moolenaar --- src/nvim/version.c | 5 ++++- test/old/testdir/test_functions.vim | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/nvim/version.c b/src/nvim/version.c index 5cd5db39b1..655ed0ec78 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -2543,11 +2543,14 @@ bool has_vim_patch(int n) // Perform a binary search. int l = 0; int h = (int)(ARRAY_SIZE(included_patches)) - 1; - while (l < h) { + while (true) { const int m = (l + h) / 2; if (included_patches[m] == n) { return true; } + if (l == h) { + break; + } if (included_patches[m] < n) { h = m; } else { diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim index 4ddb3db6fa..1f0cd1f031 100644 --- a/test/old/testdir/test_functions.vim +++ b/test/old/testdir/test_functions.vim @@ -44,6 +44,9 @@ func Test_has() " Will we ever have patch 9999? let ver = 'patch-' .. v:version / 100 .. '.' .. v:version % 100 .. '.9999' call assert_equal(0, has(ver)) + + " There actually isn't a patch 9.0.0, but this is more consistent. + call assert_equal(1, has('patch-9.0.0')) endfunc func Test_empty()