Skip to content

Commit c310cb3

Browse files
msuozzomarijnh
authored andcommitted
[vim] Fix existing and augment Vim noremap tests.
1 parent 5708251 commit c310cb3

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

test/vim_test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4280,6 +4280,8 @@ testVim('noremap', function(cm, vim, helpers) {
42804280
// keyToKey mapping support.
42814281
helpers.doKeys('i', ';', '<Esc>');
42824282
eq('w;1rd1', cm.getValue());
4283+
// unmap all mappings
4284+
CodeMirror.Vim.unmap(';');
42834285
}, { value: 'wOrd1' });
42844286
testVim('noremap_swap', function(cm, vim, helpers) {
42854287
CodeMirror.Vim.noremap('i', 'a', 'normal');
@@ -4291,7 +4293,45 @@ testVim('noremap_swap', function(cm, vim, helpers) {
42914293
// ...and 'i' should act like 'a'.
42924294
helpers.doKeys('<Esc>', 'i');
42934295
eqCursorPos(Pos(0, 1), cm.getCursor());
4296+
// unmap all mappings
4297+
CodeMirror.Vim.unmap('a', 'normal');
4298+
CodeMirror.Vim.unmap('i', 'normal');
42944299
}, { value: 'foo' });
4300+
testVim('noremap_map_interaction', function(cm, vim, helpers) {
4301+
// noremap should clobber map
4302+
CodeMirror.Vim.map(';', 'l');
4303+
CodeMirror.Vim.noremap(';', 'l');
4304+
CodeMirror.Vim.map('l', 'j');
4305+
cm.setCursor(0, 0);
4306+
helpers.doKeys(';');
4307+
eqCursorPos(Pos(0, 1), cm.getCursor());
4308+
helpers.doKeys('l');
4309+
eqCursorPos(Pos(1, 1), cm.getCursor());
4310+
// map should be able to point to a noremap
4311+
CodeMirror.Vim.map('m', ';');
4312+
helpers.doKeys('m');
4313+
eqCursorPos(Pos(1, 2), cm.getCursor());
4314+
// unmap all mappings
4315+
CodeMirror.Vim.unmap('m');
4316+
CodeMirror.Vim.unmap('l');
4317+
CodeMirror.Vim.unmap(';');
4318+
CodeMirror.Vim.unmap(';');
4319+
}, { value: 'wOrd1\nwOrd2' });
4320+
testVim('noremap_map_interaction2', function(cm, vim, helpers) {
4321+
// map should point to the most recent noremap
4322+
CodeMirror.Vim.noremap(';', 'l');
4323+
CodeMirror.Vim.map('m', ';');
4324+
CodeMirror.Vim.noremap(';', 'h');
4325+
cm.setCursor(0, 0);
4326+
helpers.doKeys('l');
4327+
eqCursorPos(Pos(0, 1), cm.getCursor());
4328+
helpers.doKeys('m');
4329+
eqCursorPos(Pos(0, 0), cm.getCursor());
4330+
// unmap all mappings
4331+
CodeMirror.Vim.unmap(';');
4332+
CodeMirror.Vim.unmap('m');
4333+
CodeMirror.Vim.unmap(';');
4334+
}, { value: 'wOrd1\nwOrd2' });
42954335

42964336
// Test event handlers
42974337
testVim('beforeSelectionChange', function(cm, vim, helpers) {

0 commit comments

Comments
 (0)