Skip to content

Commit b99af61

Browse files
zeertzjqsmjonas
authored andcommitted
fix(keywordprg): default to :help if set to empty string (neovim#19983)
1 parent 9c22085 commit b99af61

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/nvim/normal.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4278,13 +4278,12 @@ static void nv_ident(cmdarg_T *cap)
42784278
// double the length of the word. p_kp / curbuf->b_p_kp could be added
42794279
// and some numbers.
42804280
char_u *kp = *curbuf->b_p_kp == NUL ? p_kp : (char_u *)curbuf->b_p_kp; // 'keywordprg'
4281-
assert(*kp != NUL); // option.c:do_set() should default to ":help" if empty.
4282-
bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command
4283-
bool kp_help = (STRCMP(kp, ":he") == 0 || STRCMP(kp, ":help") == 0);
4281+
bool kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0 || STRCMP(kp, ":help") == 0);
42844282
if (kp_help && *skipwhite(ptr) == NUL) {
42854283
emsg(_(e_noident)); // found white space only
42864284
return;
42874285
}
4286+
bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command
42884287
size_t buf_size = n * 2 + 30 + STRLEN(kp);
42894288
char *buf = xmalloc(buf_size);
42904289
buf[0] = NUL;

test/functional/editor/K_spec.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local helpers = require('test.functional.helpers')(after_each)
2-
local eq, clear, eval, feed, retry =
3-
helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.retry
2+
local eq, clear, eval, feed, meths, retry =
3+
helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.meths, helpers.retry
44

55
describe('K', function()
66
local test_file = 'K_spec_out'
@@ -58,4 +58,11 @@ describe('K', function()
5858
helpers.neq(bufnr, eval('bufnr()'))
5959
end)
6060

61+
it('empty string falls back to :help #19298', function()
62+
meths.set_option('keywordprg', '')
63+
meths.buf_set_lines(0, 0, -1, true, {'doesnotexist'})
64+
feed('K')
65+
eq('E149: Sorry, no help for doesnotexist', meths.get_vvar('errmsg'))
66+
end)
67+
6168
end)

0 commit comments

Comments
 (0)