penguin/AstroJS

Javascript framework for my blog

commit 5d91d516aaf341a261129a8deb35f94e6327e968

author斟酌 鵬兄 <tgckpg@gmail.com>
date2016-04-16T11:07:13Z
subjectBug fix for last line shifting
commit 5d91d516aaf341a261129a8deb35f94e6327e968
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2016-04-16T11:07:13Z

    Bug fix for last line shifting
---
 botanjs/src/Components/Vim/Actions/SHIFT_LINES.js | 24 ++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js b/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js
index 1202b6c..f52ca0a 100644
--- a/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js
+++ b/botanjs/src/Components/Vim/Actions/SHIFT_LINES.js
@@ -15,10 +15,6 @@
 
 	var occurence = __import( "System.utils.Perf.CountSubstr" );
 
-	var REPL_BEFORE = 0;
-	var REPL_OFFSET = 1;
-	var REPL_LENGTH = 2;
-
 	/** @type {Components.Vim.IAction}
 	 *  Cursor @param {Components.Vim.Cursor}
 	 *  e @param {Components.Vim.ActionEvent}
@@ -261,7 +257,15 @@
 
 			if( end < j ) break;
 
-			var line = c.substring( 1 < i ? i : i - 1, c.indexOf( "\n", i ) );
+			var line = c.indexOf( "\n", i );
+			if( ~line )
+			{
+				line = c.substring( 1 < i ? i : i - 1, line );
+			}
+			else
+			{
+				line = c.substring( 1 < i ? i : i - 1 );
+			}
 
 			if( 1 < i )
 			{
@@ -291,7 +295,11 @@
 								if( !~"\t ".indexOf( line[ sj ] ) ) break;
 							}
 						}
-						else if( startC != "\t" ) break;
+						else if( startC == "\t" )
+						{
+							sj ++;
+						}
+						else break;
 					}
 
 					indentedLine = line.substring( sj );
@@ -305,7 +313,9 @@
 		}
  
 		var nPos = feeder.content.length;
-		feeder.content += "\n" + c.substring( i ) + "\n";
+		feeder.content += "\n";
+
+		if( ~i ) feeder.content += c.substring( i ) + "\n";
 		feeder.pan();
 
 		cur.moveTo( nPos );