From a325e05131576b847a71d38b2e4845346ea620e7 Mon Sep 17 00:00:00 2001 From: Harutyun Amirjanyan Date: Wed, 19 Oct 2022 13:38:40 +0400 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Xiaoyi Chen --- src/vim.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/vim.js b/src/vim.js index ad7edb7..30fc75e 100644 --- a/src/vim.js +++ b/src/vim.js @@ -2961,14 +2961,13 @@ export function initVim(CodeMirror) { var includeLineBreak = vim.insertMode || vim.visualMode; var line = Math.min(Math.max(cm.firstLine(), cur.line), cm.lastLine() ); var text = cm.getLine(line); - var maxCh = text.length - 1 + !!includeLineBreak; + var maxCh = text.length - 1 + Number(!!includeLineBreak); var ch = Math.min(Math.max(0, cur.ch), maxCh); // prevent cursor from entering surrogate pair var charCode = text.charCodeAt(ch); if (0xDC00 < charCode && charCode <0xDFFF) { var direction = 1; - if (oldCur && oldCur.line == line) { - if (oldCur.ch > ch) { + if (oldCur && oldCur.line == line && oldCur.ch > ch) { direction = -1; } }