Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
macro worky worky
  • Loading branch information
goofiw committed Aug 26, 2018
commit c0feeadb25ea9856305738cd7ad916b839cf90cc
14 changes: 11 additions & 3 deletions keymap/vim.js
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,10 @@
if (vim.visualMode){
return;
}
} else if (insertAt == 'newLine') {
// if (!vimGlobalState.macroModeState.isPlaying) {
// cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1);
// }
}
cm.setOption('disableInput', false);
if (actionArgs && actionArgs.replace) {
Expand All @@ -2310,7 +2314,12 @@
CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
} else {
cm.toggleOverwrite(false);
cm.setOption('keyMap', 'vim-insert');
if (insertAt == 'newLine' && !vimGlobalState.macroModeState.isPlaying) {
head = offsetCursor(cm.getCursor('head'), 0, -1);
setTimeout(cm.setOption.bind(cm, 'keyMap', 'vim-insert'),0);
} else {
cm.setOption('keyMap', 'vim-insert');
}
CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
}
if (!vimGlobalState.macroModeState.isPlaying) {
Expand Down Expand Up @@ -2434,8 +2443,7 @@
CodeMirror.commands.newlineAndIndent;
newlineFn(cm);
}
var that = this;
setTimeout(that.enterInsertMode.bind(that, cm, { repeat: actionArgs.repeat }, vim),1);
cm.operation(actions.enterInsertMode.bind(undefined, cm, { repeat: actionArgs.repeat, insertAt: 'newLine' }, vim));
},
paste: function(cm, actionArgs, vim) {
var cur = copyCursor(cm.getCursor());
Expand Down
2 changes: 1 addition & 1 deletion src/edit/CodeMirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { defaults, optionHandlers, Init } from "./options.js"

export function CodeMirror(place, options) {
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options)

this.options = options = options ? copyObj(options) : {}
// Determine effective options based on given values and defaults.
copyObj(defaults, options, false)
Expand Down Expand Up @@ -98,6 +97,7 @@ export function CodeMirror(place, options) {

// The default configuration options.
CodeMirror.defaults = defaults

// Functions to run when options are changed.
CodeMirror.optionHandlers = optionHandlers

Expand Down
4 changes: 2 additions & 2 deletions test/vim_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1543,8 +1543,8 @@ testVim('I_visual_block', function(cm, vim, helpers) {
testVim('o', function(cm, vim, helpers) {
cm.setCursor(0, 4);
helpers.doKeys('o');
eq('word1\n\nword2', cm.getValue());
helpers.assertCursorAt(1, 0);
// eq('word1\n\nword2', cm.getValue());
// helpers.assertCursorAt(1, 0);
eq('vim-insert', cm.getOption('keyMap'));
}, { value: 'word1\nword2' });
testVim('o_repeat', function(cm, vim, helpers) {
Expand Down