mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
fix(keycodes): simplify S- properly when D- is present (#27316)
This commit is contained in:
@@ -758,17 +758,20 @@ static int extract_modifiers(int key, int *modp, const bool simplify, bool *cons
|
|||||||
{
|
{
|
||||||
int modifiers = *modp;
|
int modifiers = *modp;
|
||||||
|
|
||||||
// Command-key and ctrl are special
|
if ((modifiers & MOD_MASK_SHIFT) && ASCII_ISALPHA(key)) {
|
||||||
if (!(modifiers & MOD_MASK_CMD) && !(modifiers & MOD_MASK_CTRL)) {
|
key = TOUPPER_ASC(key);
|
||||||
if ((modifiers & MOD_MASK_SHIFT) && ASCII_ISALPHA(key)) {
|
// With <C-S-a> we keep the shift modifier.
|
||||||
key = TOUPPER_ASC(key);
|
// With <S-a>, <A-S-a> and <S-A> we don't keep the shift modifier.
|
||||||
|
if (!(modifiers & MOD_MASK_CTRL)) {
|
||||||
modifiers &= ~MOD_MASK_SHIFT;
|
modifiers &= ~MOD_MASK_SHIFT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// <C-H> and <C-h> mean the same thing, always use "H"
|
// <C-H> and <C-h> mean the same thing, always use "H"
|
||||||
if ((modifiers & MOD_MASK_CTRL) && ASCII_ISALPHA(key)) {
|
if ((modifiers & MOD_MASK_CTRL) && ASCII_ISALPHA(key)) {
|
||||||
key = TOUPPER_ASC(key);
|
key = TOUPPER_ASC(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simplify && (modifiers & MOD_MASK_CTRL)
|
if (simplify && (modifiers & MOD_MASK_CTRL)
|
||||||
&& ((key >= '?' && key <= '_') || ASCII_ISALPHA(key))) {
|
&& ((key >= '?' && key <= '_') || ASCII_ISALPHA(key))) {
|
||||||
key = CTRL_CHR(key);
|
key = CTRL_CHR(key);
|
||||||
|
@@ -29,6 +29,10 @@ describe('mappings', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
|
add_mapping('<A-l>', '<A-l>')
|
||||||
|
add_mapping('<A-L>', '<A-L>')
|
||||||
|
add_mapping('<D-l>', '<D-l>')
|
||||||
|
add_mapping('<D-L>', '<D-L>')
|
||||||
add_mapping('<C-L>', '<C-L>')
|
add_mapping('<C-L>', '<C-L>')
|
||||||
add_mapping('<C-S-L>', '<C-S-L>')
|
add_mapping('<C-S-L>', '<C-S-L>')
|
||||||
add_mapping('<s-up>', '<s-up>')
|
add_mapping('<s-up>', '<s-up>')
|
||||||
@@ -61,7 +65,17 @@ describe('mappings', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('ok', function()
|
it('ok', function()
|
||||||
|
check_mapping('<A-l>', '<A-l>')
|
||||||
|
check_mapping('<A-L>', '<A-L>')
|
||||||
|
check_mapping('<A-S-l>', '<A-L>')
|
||||||
|
check_mapping('<A-S-L>', '<A-L>')
|
||||||
|
check_mapping('<D-l>', '<D-l>')
|
||||||
|
check_mapping('<D-L>', '<D-L>')
|
||||||
|
check_mapping('<D-S-l>', '<D-L>')
|
||||||
|
check_mapping('<D-S-L>', '<D-L>')
|
||||||
|
check_mapping('<C-l>', '<C-L>')
|
||||||
check_mapping('<C-L>', '<C-L>')
|
check_mapping('<C-L>', '<C-L>')
|
||||||
|
check_mapping('<C-S-l>', '<C-S-L>')
|
||||||
check_mapping('<C-S-L>', '<C-S-L>')
|
check_mapping('<C-S-L>', '<C-S-L>')
|
||||||
check_mapping('<s-up>', '<s-up>')
|
check_mapping('<s-up>', '<s-up>')
|
||||||
check_mapping('<c-s-up>', '<c-s-up>')
|
check_mapping('<c-s-up>', '<c-s-up>')
|
||||||
|
Reference in New Issue
Block a user