From 5f42c711cf6e7d391c57eda2ee464cf10257b4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Sun, 17 Apr 2016 17:18:55 +0800 Subject: [PATCH] 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 ++ ) {