Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vim.unmap to public api to undo Vim.map #3814

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions keymap/vim.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@
// Add user defined key bindings.
exCommandDispatcher.map(lhs, rhs, ctx);
},
unmap: function(lhs, ctx) {
exCommandDispatcher.unmap(lhs, ctx);
},
// TODO: Expose setOption and getOption as instance methods. Need to decide how to namespace
// them, or somehow make them work with the existing CodeMirror setOption/getOption API.
setOption: setOption,
Expand Down
8 changes: 7 additions & 1 deletion test/vim_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3950,7 +3950,13 @@ testVim('ex_imap', function(cm, vim, helpers) {
is(vim.insertMode);
helpers.doKeys('j', 'k');
is(!vim.insertMode);
})
});
testVim('ex_unmap_api', function(cm, vim, helpers) {
CodeMirror.Vim.map('<Alt-X>', 'gg', 'normal');
is(CodeMirror.Vim.handleKey(cm, "<Alt-X>", "normal"), "Alt-X key is mapped");
CodeMirror.Vim.unmap("<Alt-X>", "normal");
is(!CodeMirror.Vim.handleKey(cm, "<Alt-X>", "normal"), "Alt-X key is unmapped");
});

// Testing registration of functions as ex-commands and mapping to <Key>-keys
testVim('ex_api_test', function(cm, vim, helpers) {
Expand Down