From 3013d0edfce3a53ef902decfa1f70c596c828471 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 11 Nov 2020 11:18:05 -0500 Subject: vim-patch:8.2.1972: crash when recreating nested fold Problem: Crash when recreating nested fold. Solution: Check for empty growarray. (closes vim/vim#7278) https://github.com/vim/vim/commit/5e1f22ff614821b8fc7294c9dd22765acd403aeb N/A patches for version.c: vim-patch:8.2.1974: Vim9: test for has('gui_running') fails with VIMDLL Problem: Vim9: test for has('gui_running') fails with VIMDLL. Solution: Adjust the #ifdef. (Ken Takata, closes vim/vim#7276) https://github.com/vim/vim/commit/29b281ba8ddf176ae34b22e6a9b8e0ddcbcce665 --- src/nvim/fold.c | 6 +++++- src/nvim/testdir/test_fold.vim | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 96968a5d49..24a73a5b9f 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -616,7 +616,11 @@ void foldCreate(win_T *wp, pos_T start, pos_T end) break; } } - i = (int)(fp - (fold_T *)gap->ga_data); + if (gap->ga_len == 0) { + i = 0; + } else { + i = (int)(fp - (fold_T *)gap->ga_data); + } } ga_grow(gap, 1); diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim index e4baa34e4a..3c90c45952 100644 --- a/src/nvim/testdir/test_fold.vim +++ b/src/nvim/testdir/test_fold.vim @@ -805,4 +805,14 @@ func Test_move_no_folds() bwipe! endfunc +" this was crashing +func Test_fold_create_delete_create() + new + fold + fold + normal zd + fold + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 6d58f1eacef4be410c424f5f0e23c20ffdd791be Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 11 Nov 2020 14:20:28 -0500 Subject: vim-patch:8.2.1973: finding a patch number can be a bit slow Problem: Finding a patch number can be a bit slow. Solution: Use binary search. (closes vim/vim#7279) https://github.com/vim/vim/commit/232f4612e2b0a6a205ae385740078f6b8af05e75 --- src/nvim/version.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/nvim/version.c b/src/nvim/version.c index 32cb0091a3..7296c74109 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1970,11 +1970,21 @@ bool has_nvim_version(const char *const version_str) /// /// @return true if patch `n` has been included. bool has_vim_patch(int n) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { - for (int i = 0; included_patches[i] != 0; i++) { - if (included_patches[i] == n) { + // Perform a binary search. + int l = 0; + int h = (int)(ARRAY_SIZE(included_patches)) - 1; + while (l < h) { + const int m = (l + h) / 2; + if (included_patches[m] == n) { return true; } + if (included_patches[m] < n) { + h = m; + } else { + l = m + 1; + } } return false; } -- cgit