commit 3c2cb66c8fadcfc644c56ca0c049e5633790d146
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2016-04-16T14:33:02Z |
| subject | Bug fix for count movement |
commit 3c2cb66c8fadcfc644c56ca0c049e5633790d146
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2016-04-16T14:33:02Z
Bug fix for count movement
---
botanjs/src/Components/Vim/Actions/SHIFT_LINES.js | 22 ++++++++++++++++++----
botanjs/src/Components/Vim/Controls.js | 17 ++++++++++++-----
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js b/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js
index f52ca0a..0e83a39 100644
--- a/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js
+++ b/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js
@@ -28,8 +28,8 @@
this.__slineNum = Cursor.getLine().lineNum;
- this.__lines = e.count;
- debug.Info( "Open shift: " + this.__lines + " line(s) below the cursor" );
+ this.__lines = e.count - 1;
+ debug.Info( "Open shift: " + this.__lines + " line(s) from the cursor" );
this.__direction = e.kMap( ">" ) ? 1 : -1;
debug.Info( "Direction is: " + ( this.__direction == 1 ? ">" : "<" ) );
@@ -62,7 +62,7 @@
if( 1 < e.count )
{
- nline += e.count;
+ nline += ( e.count - 1 );
}
// default: >>, <<, >l, <h
@@ -79,6 +79,21 @@
if( this.__startX != currAp )
{
+ start = 0; end = 0;
+
+ if( nline )
+ {
+ if( currAp < sp )
+ {
+ start -= ( nline - 1 );
+ }
+ else
+ {
+ end += ( nline - 1 );
+ }
+ console.log( start, end );
+ }
+
if( currAp < sp )
{
sp = sp + currAp;
@@ -86,7 +101,6 @@
sp = sp - currAp;
}
- start = end = 0;
for( var i = 0; i < currAp; i ++ )
{
if( feeder.content[ i ] == "\n" )
diff --git a/botanjs/src/Components/Vim/Controls.js b/botanjs/src/Components/Vim/Controls.js
index cb56006..36d0e04 100644
--- a/botanjs/src/Components/Vim/Controls.js
+++ b/botanjs/src/Components/Vim/Controls.js
@@ -407,7 +407,13 @@
_self.__mod = false;
}, ANY_KEY );
break;
- case _0: case _1: case _2: case _3: case _4:
+ case _0: // No 0 for first count
+ if( !this.__compositeReg )
+ {
+ mod = false;
+ break;
+ }
+ case _1: case _2: case _3: case _4:
case _5: case _6: case _7: case _8: case _9:
var Count = e.key;
@@ -470,11 +476,12 @@
switch( kCode )
{
case BACKSPACE: this.__cMoveX( -1, true ); break; // Backspace, go back 1 char
- case H: this.__cMoveX( -1 ); break; // Left
- case L: this.__cMoveX( 1 ); break; // Right
- case K: this.__cMoveY( -1 ); break; // Up
+ case H: this.__cMoveX( - e.count ); break; // Left
+ case L: this.__cMoveX( e.count ); break; // Right
+ case DASH: case GECKO_DASH:
+ case K: this.__cMoveY( - e.count ); break; // Up
case ENTER:
- case J: this.__cMoveY( 1 ); break; // Down
+ case J: this.__cMoveY( e.count ); break; // Down
case CTRL + F: // Page Down
if( cfeeder.firstBuffer.nextLine.placeholder )