Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Xiaoyi Chen <cxychina@gmail.com>
  • Loading branch information
nightwing and xyc authored Oct 19, 2022
1 parent e98ab56 commit a325e05
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/vim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit a325e05

Please sign in to comment.