commit 5311dc043df35bc528c533c33d3a3e1fe9b94598
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2017-03-07T04:07:58Z |
| subject | Fixed a cursor jumping issue for word-wrapped lines |
commit 5311dc043df35bc528c533c33d3a3e1fe9b94598
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2017-03-07T04:07:58Z
Fixed a cursor jumping issue for word-wrapped lines
---
botanjs/src/Components/Vim/Cursor.js | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/botanjs/src/Components/Vim/Cursor.js b/botanjs/src/Components/Vim/Cursor.js
index f6cd72a..be9c9a0 100644
--- a/botanjs/src/Components/Vim/Cursor.js
+++ b/botanjs/src/Components/Vim/Cursor.js
@@ -131,9 +131,14 @@
}
var jumpY = expLineNum - lastLineNum;
- var jumpX = aPos < lineStart ? lineStart - aPos : aPos - lineStart;
+ if( jumpY ) this.moveY( jumpY );
+ pline = this.getLine();
+
+ var jumpX = aPos < lineStart ? lineStart - aPos : aPos - lineStart;
var kX = jumpX - pline.content.length;
+
+ // This handles word-wrapped long line phantom "\n"
while( 0 < kX )
{
jumpX ++;
@@ -142,8 +147,6 @@
kX -= pline.content.length;
}
- if( jumpY ) this.moveY( jumpY );
-
// This is needed because first line does not contain the first "\n" character
if( 0 < this.getLine().lineNum && lineStart <= aPos ) jumpX --;