fix(help): fix CTRL character issue for :help {subject} #39537

Problem:
The argument to `:help` is normalized to fit the general tag format.
I.e. i^U-default, iCTRL-U-default and i_CTRL_U-default should all point
to the i_CTRL_U-default tag. Our normalization adds an underscore around
the CTRL keycode, e.g. iCTRL-GCTRL-J becomes i_CTRL-G_CTRL-J. That's not
necessary if the following part starts with a dash, like the case of
iCTRL-U-default.

Solution:
Do not insert an underscore if the following character is a dash/minus
(-).
This commit is contained in:
Yochem van Rosmalen
2026-05-01 12:28:16 +02:00
committed by GitHub
parent 858cd3d106
commit 84ae70c172
2 changed files with 2 additions and 1 deletions

View File

@@ -108,7 +108,7 @@ function M.escape_subject(word)
-- E.g. 'iCTRL-GCTRL-J' --> 'i_CTRL-G_CTRL-J'
-- Only exception: 'CTRL-{character}'
word = word:gsub('([^_])CTRL%-', '%1_CTRL-')
word = word:gsub('(CTRL%-[^{])([^_\\])', '%1_%2')
word = word:gsub('(CTRL%-[^{])([^-_\\])', '%1_%2')
-- Skip function arguments
-- E.g. 'abs({expr})' --> 'abs'