penguin/AstroJS

Javascript framework for my blog

commit 5f42c711cf6e7d391c57eda2ee464cf10257b4d6

author斟酌 鵬兄 <tgckpg@gmail.com>
date2016-04-17T09:18:55Z
subjectBug fix UNDO / REDO error for indent chopping
commit 5f42c711cf6e7d391c57eda2ee464cf10257b4d6
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2016-04-17T09:18:55Z

    Bug fix UNDO / REDO error for indent chopping
---
 botanjs/src/Components/Vim/Actions/INSERT.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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