Skip to content
Merged
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
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,15 @@ const vimPlugin = ViewPlugin.fromClass(
decorations = Decoration.none;
waitForCopy = false;
handleKey(e: KeyboardEvent, view: EditorView) {
const key = CodeMirror.vimKey(e);
const cm = this.cm;
if (!key) return;
const rawKey = CodeMirror.vimKey(e);
if (!rawKey) return;

const cm = this.cm;
let vim = cm.state.vim;
if (!vim) return;

const key = vim.expectLiteralNext ? rawKey : Vim.langmapRemapKey(rawKey);

// clear search highlight
if (
key == "<Esc>" &&
Expand Down
14 changes: 4 additions & 10 deletions src/vim.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,9 @@ export function initVim(CodeMirror) {
langmap: function(langmapString, remapCtrl = true) {
updateLangmap(langmapString, remapCtrl);
},
langmapRemapKey: function(key) {
return langmapRemapKey(key);
},
// 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 Expand Up @@ -883,11 +886,9 @@ export function initVim(CodeMirror) {
* execute the bound command if a a key is matched. The function always
* returns true.
*/
findKey: function(cm, rawKey, origin) {
findKey: function(cm, key, origin) {
var vim = maybeInitVimState(cm);

let key = vim.expectLiteralNext ? rawKey : langmapRemapKey(rawKey);

function handleMacroRecording() {
var macroModeState = vimGlobalState.macroModeState;
if (macroModeState.isRecording) {
Expand Down Expand Up @@ -2687,10 +2688,6 @@ export function initVim(CodeMirror) {
cm.scrollTo(null, y);
},
replayMacro: function(cm, actionArgs, vim) {
// when replaying a macro, we must not "double remap" characters
const savedLangMap = langmap;
langmap = parseLangmap('');

var registerName = actionArgs.selectedCharacter;
var repeat = actionArgs.repeat;
var macroModeState = vimGlobalState.macroModeState;
Expand All @@ -2702,9 +2699,6 @@ export function initVim(CodeMirror) {
while(repeat--){
executeMacroRegister(cm, vim, macroModeState, registerName);
}

// restore langmap
langmap = savedLangMap;
},
enterMacroRecordMode: function(cm, actionArgs) {
var macroModeState = vimGlobalState.macroModeState;
Expand Down