diff --git a/botanjs/src/Components/Vim/Actions/DELETE.js b/botanjs/src/Components/Vim/Actions/DELETE.js index 1f58fae..6f1d33d 100644 --- a/botanjs/src/Components/Vim/Actions/DELETE.js +++ b/botanjs/src/Components/Vim/Actions/DELETE.js @@ -15,7 +15,7 @@ var occurence = __import( "System.utils.Perf.CountSubstr" ); /** @type {Components.Vim.IAction} */ - var DELETE = function( Cursor ) + var DELETE = function( Cursor, e ) { /** @type {Components.Vim.Cursor} */ this.__cursor = Cursor; @@ -23,6 +23,10 @@ this.__startX = Cursor.aPos; this.__panY = this.__cursor.feeder.panY; + this.__cMode = e.kMap( "c" ); + this.__cMode_c = false; + this.__enterEvent = e; + Cursor.suppressEvent(); }; @@ -30,7 +34,26 @@ DELETE.prototype.dispose = function() { - this.__cursor.unsuppressEvent(); + var cur = this.__cursor; + cur.unsuppressEvent(); + + if( this.__cMode ) + { + if( this.__cMode_c ) // Append, a + { + cur.fixTab(); + cur.moveX( 1, false, true, true ); + } + else // Insert, i + { + cur.moveX( -1, true ); + cur.moveX( 1, true, true, true ); + } + + setTimeout( function() { + cur.openAction( "INSERT", this.__enterEvent ); + }, 20 ); + } }; DELETE.prototype.handler = function( e, sp, newLine ) @@ -117,6 +140,13 @@ sp = cur.aPos; cur.lineStart(); } + else if( this.__cMode && e.kMap( "c" ) ) + { + cur.lineEnd(); + sp = cur.aPos; + cur.lineStart( true ); + this.__cMode_c = true; + } else if( e.range ) { sp = e.range.close; diff --git a/botanjs/src/Components/Vim/Controls.js b/botanjs/src/Components/Vim/Controls.js index bb22ce4..5f4e4d7 100644 --- a/botanjs/src/Components/Vim/Controls.js +++ b/botanjs/src/Components/Vim/Controls.js @@ -311,6 +311,7 @@ break; case D: // Del with motion + case C: // Then insert ccur.openAction( "DELETE", e ); break; case Y: // Yank with motion @@ -743,6 +744,7 @@ { j += lines[i].content.length; } + j += Math.max( 0, Math.floor( j / dispLine.cols ) - 1 ); ccur.moveX( j ); } } diff --git a/botanjs/src/Components/Vim/Cursor.js b/botanjs/src/Components/Vim/Cursor.js index 2bf2eb4..18e327b 100644 --- a/botanjs/src/Components/Vim/Cursor.js +++ b/botanjs/src/Components/Vim/Cursor.js @@ -275,7 +275,6 @@ var ntabs = occurence( rline.substring( s + 1, e + 1 ), "\t" ); if( 1 < ntabs && rline[ e ] == "\t" ) ntabs --; x += ntabs * tabStep + isLF; - x += Math.max( 0, Math.floor( d / line.cols ) - 1 ); // Reset the distance to 1 as x is now calculated d = 1;