Bug fix UNDO / REDO error for indent chopping

This commit is contained in:
斟酌 鵬兄 2016-04-17 17:18:55 +08:00
parent 3c2cb66c8f
commit 5f42c711cf
1 changed files with 7 additions and 1 deletions

View File

@ -37,6 +37,7 @@
this.__stator = new Stator( Cursor ); this.__stator = new Stator( Cursor );
this.__minReach = 0; this.__minReach = 0;
this.__insertLen = 0; this.__insertLen = 0;
this.__chopIndent = false;
// Initialize this stack // Initialize this stack
this.__rec( "", true ); this.__rec( "", true );
@ -52,6 +53,7 @@
INSERT.prototype.dispose = function() INSERT.prototype.dispose = function()
{ {
if( this.__chopIndent ) this.__realizeIndent();
if( this.__cancelIndent() ) if( this.__cancelIndent() )
{ {
this.__cursor.feeder.pan(); this.__cursor.feeder.pan();
@ -175,6 +177,8 @@
var f = cur.aPos; var f = cur.aPos;
var chopIndent = feeder.content[ f ] != "\n";
feeder.content = feeder.content =
feeder.content.substring( 0, f ) feeder.content.substring( 0, f )
+ inputChar + inputChar
@ -187,6 +191,7 @@
cur.moveY( 1 ); cur.moveY( 1 );
cur.lineStart(); cur.lineStart();
this.__autoIndent( e ); this.__autoIndent( e );
this.__chopIndent = chopIndent;
} }
else else
{ {
@ -218,6 +223,7 @@
INSERT.prototype.__autoIndent = function( e ) INSERT.prototype.__autoIndent = function( e )
{ {
var oInd = this.__phantomIndent;
var carried = this.__cancelIndent(); var carried = this.__cancelIndent();
var cur = this.__cursor; var cur = this.__cursor;
@ -237,7 +243,7 @@
line = feeder.content.substring( i + 1, j - 1 ); line = feeder.content.substring( i + 1, j - 1 );
} }
var inDel = ""; var inDel = carried ? oInd[ IN_DEL ] : "";
// Indent removed // Indent removed
for( var ir = f; "\t ".indexOf( feeder.content[ ir ] ) != -1; ir ++ ) for( var ir = f; "\t ".indexOf( feeder.content[ ir ] ) != -1; ir ++ )
{ {