[vim] Fix vim-mode-change event being signalled twice
This commit is contained in:
parent
a66f466e33
commit
b42ee0965e
|
@ -3203,7 +3203,7 @@
|
||||||
vim.visualMode = false;
|
vim.visualMode = false;
|
||||||
vim.visualLine = false;
|
vim.visualLine = false;
|
||||||
vim.visualBlock = false;
|
vim.visualBlock = false;
|
||||||
CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
|
if (!vim.insertMode) CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
|
||||||
clearFakeCursor(vim);
|
clearFakeCursor(vim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1153,6 +1153,41 @@ testVim('s_visual_block', function(cm, vim, helpers) {
|
||||||
eq('1hello{\n world\n', cm.getValue());
|
eq('1hello{\n world\n', cm.getValue());
|
||||||
}, {value: '1234\n5678\nabcdefg\n'});
|
}, {value: '1234\n5678\nabcdefg\n'});
|
||||||
|
|
||||||
|
// Test mode change event. It should only fire once per mode transition.
|
||||||
|
testVim('on_mode_change', function(cm, vim, helpers) {
|
||||||
|
var modeHist = [];
|
||||||
|
function callback(arg) {
|
||||||
|
var subMode = arg.subMode ? ':' + arg.subMode : '';
|
||||||
|
modeHist.push(arg.mode + subMode);
|
||||||
|
}
|
||||||
|
helpers.doKeys('<Esc>', '<Esc>');
|
||||||
|
cm.on('vim-mode-change', callback);
|
||||||
|
function test(key, mode) {
|
||||||
|
modeHist.length = 0;
|
||||||
|
helpers.doKeys(key);
|
||||||
|
eq(modeHist.join(';'), mode);
|
||||||
|
}
|
||||||
|
test('v', 'visual');
|
||||||
|
test('c', 'insert');
|
||||||
|
test('<Esc>', 'normal');
|
||||||
|
test('<C-v>', 'visual:blockwise');
|
||||||
|
test('I', 'insert');
|
||||||
|
test('<Esc>', 'normal');
|
||||||
|
test('R', 'replace');
|
||||||
|
test('x', '');
|
||||||
|
test('<C-[>', 'normal');
|
||||||
|
test('v', 'visual');
|
||||||
|
test('V', 'visual:linewise');
|
||||||
|
test('<C-v>', 'visual:blockwise');
|
||||||
|
test('v', 'visual');
|
||||||
|
test('<C-c>', 'normal');
|
||||||
|
test('a', 'insert');
|
||||||
|
test('<Esc>', 'normal');
|
||||||
|
test('v', 'visual');
|
||||||
|
test(':', ''); // Event for Command-line mode not implemented.
|
||||||
|
test('y', 'normal');
|
||||||
|
});
|
||||||
|
|
||||||
// Swapcase commands edit in place and do not modify registers.
|
// Swapcase commands edit in place and do not modify registers.
|
||||||
testVim('g~w_repeat', function(cm, vim, helpers) {
|
testVim('g~w_repeat', function(cm, vim, helpers) {
|
||||||
// Assert that dw does delete newline if it should go to the next line, and
|
// Assert that dw does delete newline if it should go to the next line, and
|
||||||
|
|
Loading…
Reference in New Issue