Fixed reverse FIND does not work properly

This commit is contained in:
斟酌 鵬兄 2017-03-07 15:01:40 +08:00
parent 5311dc043d
commit 08865e062e
3 changed files with 25 additions and 2 deletions

View File

@ -121,6 +121,7 @@
cur.moveY( -1 );
cur.lineStart();
}
// Remove to Cursor jumps
else if( this.__startX < currAp )
{
// Swap the movement
@ -128,6 +129,10 @@
// position to the earlier position
sp = currAp;
cur.moveTo( this.__startX );
// Special case for cw dn cursor jumps that
// does not remove the start position
if( e.kMap( "w" ) || e.kMap( "n" ) ) sp --;
}
}
// Remove the current line

View File

@ -102,6 +102,8 @@
var r;
var Hit;
var FirstHit;
var l = 0;
var PrevStack = [];
var LoopGuard;
@ -125,6 +127,7 @@
}
PrevStack.push( r.index );
l ++;
LoopGuard = r.index;
}
@ -132,11 +135,19 @@
if( e.kMap( "N" ) )
{
Hit = PrevStack[ PrevStack.length - 2 ];
// The search loop above always search for next match
// So use the previous match
Hit = PrevStack[ l - 1 ];
// Adjust if cursor is already in the previous match
if( Hit == p ) Hit = PrevStack[ l - 2 ];
if( Hit == undefined )
{
this.__msg = Mesg( "SEARCH_HIT_TOP" );
// This resets the exec state in previous loop
search = new RegExp( search );
while( ( r = search.exec( content ) ) !== null ) Hit = r.index;
}
}

View File

@ -131,7 +131,14 @@
}
var jumpY = expLineNum - lastLineNum;
if( jumpY ) this.moveY( jumpY );
if( jumpY )
{
this.moveY( jumpY );
// Because moveTo is a direct jump function
// We'll auto reveal the target line here
if( this.feeder.moreAt == this.Y ) this.moveY( 1 );
}
pline = this.getLine();