Skip to content

Commit 0426274

Browse files
nightwingmarijnh
authored andcommitted
[vim] exit character exit mode on <C-c>
1 parent 52de20c commit 0426274

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

keymap/vim.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,9 @@
11101110
}
11111111
}
11121112
if (bestMatch.keys.slice(-11) == '<character>') {
1113-
inputState.selectedCharacter = lastChar(keys);
1113+
var character = lastChar(keys);
1114+
if (!character) return {type: 'none'};
1115+
inputState.selectedCharacter = character;
11141116
}
11151117
return {type: 'full', command: bestMatch};
11161118
},
@@ -2704,7 +2706,7 @@
27042706
}
27052707
}
27062708
function lastChar(keys) {
2707-
var match = /^.*(<[\w\-]+>)$/.exec(keys);
2709+
var match = /^.*(<[^>]+>)$/.exec(keys);
27082710
var selectedCharacter = match ? match[1] : keys.slice(-1);
27092711
if (selectedCharacter.length > 1){
27102712
switch(selectedCharacter){
@@ -2715,6 +2717,7 @@
27152717
selectedCharacter=' ';
27162718
break;
27172719
default:
2720+
selectedCharacter='';
27182721
break;
27192722
}
27202723
}

test/vim_test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,13 @@ testVim('r', function(cm, vim, helpers) {
16071607
cm.setCursor(0, 4);
16081608
helpers.doKeys('v', 'j', 'h', 'r', '<Space>');
16091609
eq('wuuu \n her', cm.getValue(),'Replacing selection by space-characters failed');
1610+
cm.setValue("ox");
1611+
helpers.doKeys('r', '<C-c>');
1612+
eq('ox', cm.getValue());
1613+
helpers.doKeys('r', '<Del>');
1614+
eq('ox', cm.getValue());
1615+
helpers.doKeys('r', '<CR>');
1616+
eq('\nx', cm.getValue());
16101617
}, { value: 'wordet\nanother' });
16111618
testVim('r_visual_block', function(cm, vim, helpers) {
16121619
cm.setCursor(2, 3);

0 commit comments

Comments
 (0)