diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-29 05:58:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 05:58:32 +0800 |
commit | b21980bd607e952fe52957aec3214367bd48527b (patch) | |
tree | ddb4c408123460b79849edef281818bc083d1ac1 | |
parent | 88c32b5eba9fa7072bb4a76a8dbb73c6603165be (diff) | |
download | rneovim-b21980bd607e952fe52957aec3214367bd48527b.tar.gz rneovim-b21980bd607e952fe52957aec3214367bd48527b.tar.bz2 rneovim-b21980bd607e952fe52957aec3214367bd48527b.zip |
fix(keywordprg): default to :help if set to empty string (#19983)
-rw-r--r-- | src/nvim/normal.c | 5 | ||||
-rw-r--r-- | test/functional/editor/K_spec.lua | 11 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 31646f686d..cab380003d 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4278,13 +4278,12 @@ static void nv_ident(cmdarg_T *cap) // double the length of the word. p_kp / curbuf->b_p_kp could be added // and some numbers. char_u *kp = *curbuf->b_p_kp == NUL ? p_kp : (char_u *)curbuf->b_p_kp; // 'keywordprg' - assert(*kp != NUL); // option.c:do_set() should default to ":help" if empty. - bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command - bool kp_help = (STRCMP(kp, ":he") == 0 || STRCMP(kp, ":help") == 0); + bool kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0 || STRCMP(kp, ":help") == 0); if (kp_help && *skipwhite(ptr) == NUL) { emsg(_(e_noident)); // found white space only return; } + bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command size_t buf_size = n * 2 + 30 + STRLEN(kp); char *buf = xmalloc(buf_size); buf[0] = NUL; diff --git a/test/functional/editor/K_spec.lua b/test/functional/editor/K_spec.lua index 8ad81ac3d6..3b5580540f 100644 --- a/test/functional/editor/K_spec.lua +++ b/test/functional/editor/K_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) -local eq, clear, eval, feed, retry = - helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.retry +local eq, clear, eval, feed, meths, retry = + helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.meths, helpers.retry describe('K', function() local test_file = 'K_spec_out' @@ -58,4 +58,11 @@ describe('K', function() helpers.neq(bufnr, eval('bufnr()')) end) + it('empty string falls back to :help #19298', function() + meths.set_option('keywordprg', '') + meths.buf_set_lines(0, 0, -1, true, {'doesnotexist'}) + feed('K') + eq('E149: Sorry, no help for doesnotexist', meths.get_vvar('errmsg')) + end) + end) |