commit d6a27ca87eeccd71aa0582316e959f1374cc537d
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2017-01-25T07:42:05Z |
| subject | First char INSERT issue due to prev commit |
commit d6a27ca87eeccd71aa0582316e959f1374cc537d
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2017-01-25T07:42:05Z
First char INSERT issue due to prev commit
---
botanjs/src/Components/Vim/Actions/INSERT.js | 7 ++++--
botanjs/src/Components/Vim/Controls.js | 13 ++++++++---
botanjs/src/Components/Vim/Cursor.js | 34 +++++++++++++++++++++++++++-
botanjs/src/externs/Components.Vim.Cursor.js | 2 ++
4 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/botanjs/src/Components/Vim/Actions/INSERT.js b/botanjs/src/Components/Vim/Actions/INSERT.js
index bec9396..be97b56 100644
--- a/botanjs/src/Components/Vim/Actions/INSERT.js
+++ b/botanjs/src/Components/Vim/Actions/INSERT.js
@@ -61,6 +61,7 @@
this.__msg = "";
this.__rec( "", true );
this.__cursor.moveX( -1, false, false, true );
+ this.__cursor.fixTab();
};
INSERT.prototype.__rec = function( c, newRec )
@@ -129,14 +130,16 @@
this.__contentUndo = feeder.content.substr( f, 1 ) + this.__contentUndo;
}
+ cur.moveX(
+ feeder.content[f] == "\t" ? -feeder.firstBuffer.tabWidth : -1
+ , true, true, true );
+
feeder.content =
feeder.content.substring( 0, f )
+ feeder.content.substring( f + 1 );
feeder.pan();
- cur.moveX( -1, true, true );
-
if( 0 < this.__insertLen ) this.__insertLen --;
this.__punch --;
}
diff --git a/botanjs/src/Components/Vim/Controls.js b/botanjs/src/Components/Vim/Controls.js
index 0c34dcc..ba2fbc8 100644
--- a/botanjs/src/Components/Vim/Controls.js
+++ b/botanjs/src/Components/Vim/Controls.js
@@ -259,13 +259,20 @@
{
case SHIFT + A: // Append at the line end
ccur.lineEnd();
- ccur.moveX( 1, true, true, true );
+ ccur.moveX( 1, false, true, true );
ccur.openAction( "INSERT", e );
break;
case I: // Insert
- ccur.moveX( -1 );
+ if( 0 < ccur.X )
+ {
+ ccur.moveX( -1, true );
+ ccur.moveX( 1, true, true, true );
+ }
+ ccur.openAction( "INSERT", e );
+ break;
case A: // Append
- ccur.moveX( 1, true, true, true );
+ ccur.fixTab();
+ ccur.moveX( 1, false, true, true );
ccur.openAction( "INSERT", e );
break;
case SHIFT + I: // Append at line start
diff --git a/botanjs/src/Components/Vim/Cursor.js b/botanjs/src/Components/Vim/Cursor.js
index e59b69d..ad3a5ed 100644
--- a/botanjs/src/Components/Vim/Cursor.js
+++ b/botanjs/src/Components/Vim/Cursor.js
@@ -204,8 +204,33 @@
}
// Hacky tab compensations
- if( !skipTab )
+ if( skipTab )
{
+ // Handles INSERT on first tab char
+ if( penetrate && 0 < d )
+ {
+ if( ( content.length - 1 ) <= x )
+ {
+ this.moveY( 1 );
+ this.X = 0;
+ this.updatePosition();
+ return;
+ }
+ }
+ }
+ else
+ {
+ // Handles INSERT on first tab char
+ if( penetrate )
+ {
+ if( line.content[0] == "\t" && x < tabStep )
+ {
+ this.moveY( -1 );
+ this.lineEnd( phantomSpace );
+ return;
+ }
+ }
+
var s = this.aX;
var a = rline[ s + d ];
var e = s;
@@ -283,6 +308,13 @@
};
+ // fix the tab position
+ Cursor.prototype.fixTab = function()
+ {
+ this.moveX( 1, false, true );
+ this.moveX( -1 );
+ };
+
Cursor.prototype.lineStart = function( atWord )
{
if( atWord )
diff --git a/botanjs/src/externs/Components.Vim.Cursor.js b/botanjs/src/externs/Components.Vim.Cursor.js
index 5bdc8b1..2b60b30 100644
--- a/botanjs/src/externs/Components.Vim.Cursor.js
+++ b/botanjs/src/externs/Components.Vim.Cursor.js
@@ -23,6 +23,8 @@ Components.Vim.Cursor.lineEnd;
/** @type Function */
Components.Vim.Cursor.updatePosition;
/** @type Function */
+Components.Vim.Cursor.fixTab;
+/** @type Function */
Components.Vim.Cursor.openAction;
/** @type Function */
Components.Vim.Cursor.openRunAction;