commit 62d2de3800fa71d92b43f58a474b1ed0a76008aa
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2016-03-31T20:52:41Z |
| subject | fixed DEL the end resulting wrong pos |
commit 62d2de3800fa71d92b43f58a474b1ed0a76008aa
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2016-03-31T20:52:41Z
fixed DEL the end resulting wrong pos
---
botanjs/src/Components/Vim/Actions/DELETE.js | 6 ------
botanjs/src/Components/Vim/Actions/INSERT.js | 13 ++++++++-----
botanjs/src/Components/Vim/Controls.js | 2 +-
botanjs/src/Components/Vim/Cursor.js | 10 +++++++++-
botanjs/src/Components/Vim/Syntax/Analyzer.js | 17 ++++++++++-------
5 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/botanjs/src/Components/Vim/Actions/DELETE.js b/botanjs/src/Components/Vim/Actions/DELETE.js
index 16daab5..1683c32 100644
--- a/botanjs/src/Components/Vim/Actions/DELETE.js
+++ b/botanjs/src/Components/Vim/Actions/DELETE.js
@@ -164,12 +164,6 @@
var stator = new Stator( cur, s );
var stack = new Stack();
- c = c[ e + 1 ];
- if( c == "\n" || c == undefined )
- {
- cur.moveX( -1 );
- }
-
var f = stator.save( 0, removed );
stack.store( function() {
f();
diff --git a/botanjs/src/Components/Vim/Actions/INSERT.js b/botanjs/src/Components/Vim/Actions/INSERT.js
index 0e805ee..f119a30 100644
--- a/botanjs/src/Components/Vim/Actions/INSERT.js
+++ b/botanjs/src/Components/Vim/Actions/INSERT.js
@@ -33,12 +33,19 @@
// Initialize this stack
this.__rec( "", true );
+
+ var l = this.__cursor.feeder.firstBuffer.cols;
+ var msg = Mesg( "INSERT" );
+
+ for( var i = msg.length; i < l; i ++ ) msg += " ";
+ this.__msg = msg;
};
INSERT.prototype.allowMovement = false;
INSERT.prototype.dispose = function()
{
+ this.__msg = "";
this.__rec( "", true );
this.__cursor.moveX( -1 );
};
@@ -158,11 +165,7 @@
INSERT.prototype.getMessage = function()
{
- var l = this.__cursor.feeder.firstBuffer.cols;
- var msg = Mesg( "INSERT" );
-
- for( var i = msg.length; i < l; i ++ ) msg += " ";
- return msg;
+ return this.__msg;
};
ns[ NS_EXPORT ]( EX_CLASS, "INSERT", INSERT );
diff --git a/botanjs/src/Components/Vim/Controls.js b/botanjs/src/Components/Vim/Controls.js
index 8dc0ac3..587cda3 100644
--- a/botanjs/src/Components/Vim/Controls.js
+++ b/botanjs/src/Components/Vim/Controls.js
@@ -179,7 +179,7 @@
case SHIFT + A: // Append at the line end
ccur.lineEnd();
case A: // Append
- this.__cMoveX( 1, true, true );
+ ccur.moveX( 1, true, true );
case I: // Insert
ccur.openAction( "INSERT" );
break;
diff --git a/botanjs/src/Components/Vim/Cursor.js b/botanjs/src/Components/Vim/Cursor.js
index 3c4927f..07e07b4 100644
--- a/botanjs/src/Components/Vim/Cursor.js
+++ b/botanjs/src/Components/Vim/Cursor.js
@@ -124,6 +124,8 @@
jumpX += Math.ceil( jumpX / pline.cols ) - 1;
if( jumpY ) this.moveY( jumpY );
+
+ // This needed because first line does not contain first "\n" character
if( 0 < this.getLine().lineNum && lineStart <= aPos ) jumpX --;
this.moveX( - Number.MAX_VALUE );
@@ -135,13 +137,14 @@
Cursor.prototype.moveX = function( d, penetrate, phantomSpace )
{
var x = this.pX;
+ var updatePx = Boolean( d );
+
if( 0 < this.__off )
{
d += this.__off;
this.__off = 0;
}
- var updatePx = Boolean( d );
if( updatePx ) x = this.X + d;
if( !d ) d = 1;
@@ -368,6 +371,9 @@
Cursor.prototype.openAction = function( name )
{
if( this.action ) this.action.dispose();
+
+ debug.Info( "openAction: " + name );
+
this.action = new (Actions[ name ])( this );
this.__pulseMsg = null;
@@ -381,6 +387,8 @@
this.__pulseMsg = this.action.getMessage();
this.action = null;
+ debug.Info( "closeAction" );
+
// Reset the analyzed content
this.Vim.contentAnalyzer.reset();
diff --git a/botanjs/src/Components/Vim/Syntax/Analyzer.js b/botanjs/src/Components/Vim/Syntax/Analyzer.js
index 54014ce..c10e441 100644
--- a/botanjs/src/Components/Vim/Syntax/Analyzer.js
+++ b/botanjs/src/Components/Vim/Syntax/Analyzer.js
@@ -249,15 +249,18 @@
}
- var tMatch = SetParent( tokPairs, highest );
- var oMatch = tMatch;
+ if( highest )
+ {
+ var tMatch = SetParent( tokPairs, highest );
+ var oMatch = tMatch;
- do {
- oMatch.__open ++;
- oMatch.__close --;
- } while( oMatch = oMatch.parent )
+ do {
+ oMatch.__open ++;
+ oMatch.__close --;
+ } while( oMatch = oMatch.parent )
- if( highest ) return tMatch;
+ return tMatch;
+ }
return new TokenMatch();
};