fixed DEL the end resulting wrong pos

This commit is contained in:
斟酌 鵬兄 2016-04-01 04:52:41 +08:00
parent a927c90134
commit 62d2de3800
5 changed files with 28 additions and 20 deletions

View File

@ -164,12 +164,6 @@
var stator = new Stator( cur, s ); var stator = new Stator( cur, s );
var stack = new Stack(); var stack = new Stack();
c = c[ e + 1 ];
if( c == "\n" || c == undefined )
{
cur.moveX( -1 );
}
var f = stator.save( 0, removed ); var f = stator.save( 0, removed );
stack.store( function() { stack.store( function() {
f(); f();

View File

@ -33,12 +33,19 @@
// Initialize this stack // Initialize this stack
this.__rec( "", true ); 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.allowMovement = false;
INSERT.prototype.dispose = function() INSERT.prototype.dispose = function()
{ {
this.__msg = "";
this.__rec( "", true ); this.__rec( "", true );
this.__cursor.moveX( -1 ); this.__cursor.moveX( -1 );
}; };
@ -158,11 +165,7 @@
INSERT.prototype.getMessage = function() INSERT.prototype.getMessage = function()
{ {
var l = this.__cursor.feeder.firstBuffer.cols; return this.__msg;
var msg = Mesg( "INSERT" );
for( var i = msg.length; i < l; i ++ ) msg += " ";
return msg;
}; };
ns[ NS_EXPORT ]( EX_CLASS, "INSERT", INSERT ); ns[ NS_EXPORT ]( EX_CLASS, "INSERT", INSERT );

View File

@ -179,7 +179,7 @@
case SHIFT + A: // Append at the line end case SHIFT + A: // Append at the line end
ccur.lineEnd(); ccur.lineEnd();
case A: // Append case A: // Append
this.__cMoveX( 1, true, true ); ccur.moveX( 1, true, true );
case I: // Insert case I: // Insert
ccur.openAction( "INSERT" ); ccur.openAction( "INSERT" );
break; break;

View File

@ -124,6 +124,8 @@
jumpX += Math.ceil( jumpX / pline.cols ) - 1; jumpX += Math.ceil( jumpX / pline.cols ) - 1;
if( jumpY ) this.moveY( jumpY ); if( jumpY ) this.moveY( jumpY );
// This needed because first line does not contain first "\n" character
if( 0 < this.getLine().lineNum && lineStart <= aPos ) jumpX --; if( 0 < this.getLine().lineNum && lineStart <= aPos ) jumpX --;
this.moveX( - Number.MAX_VALUE ); this.moveX( - Number.MAX_VALUE );
@ -135,13 +137,14 @@
Cursor.prototype.moveX = function( d, penetrate, phantomSpace ) Cursor.prototype.moveX = function( d, penetrate, phantomSpace )
{ {
var x = this.pX; var x = this.pX;
var updatePx = Boolean( d );
if( 0 < this.__off ) if( 0 < this.__off )
{ {
d += this.__off; d += this.__off;
this.__off = 0; this.__off = 0;
} }
var updatePx = Boolean( d );
if( updatePx ) x = this.X + d; if( updatePx ) x = this.X + d;
if( !d ) d = 1; if( !d ) d = 1;
@ -368,6 +371,9 @@
Cursor.prototype.openAction = function( name ) Cursor.prototype.openAction = function( name )
{ {
if( this.action ) this.action.dispose(); if( this.action ) this.action.dispose();
debug.Info( "openAction: " + name );
this.action = new (Actions[ name ])( this ); this.action = new (Actions[ name ])( this );
this.__pulseMsg = null; this.__pulseMsg = null;
@ -381,6 +387,8 @@
this.__pulseMsg = this.action.getMessage(); this.__pulseMsg = this.action.getMessage();
this.action = null; this.action = null;
debug.Info( "closeAction" );
// Reset the analyzed content // Reset the analyzed content
this.Vim.contentAnalyzer.reset(); this.Vim.contentAnalyzer.reset();

View File

@ -249,6 +249,8 @@
} }
if( highest )
{
var tMatch = SetParent( tokPairs, highest ); var tMatch = SetParent( tokPairs, highest );
var oMatch = tMatch; var oMatch = tMatch;
@ -257,7 +259,8 @@
oMatch.__close --; oMatch.__close --;
} while( oMatch = oMatch.parent ) } while( oMatch = oMatch.parent )
if( highest ) return tMatch; return tMatch;
}
return new TokenMatch(); return new TokenMatch();
}; };