mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 06:41:42 +08:00
Updated definiton of move_word, more intuitive behaviour when a token consists only of non-alphanumerics
darcs-hash:20060831004525-ac50b-aa6675809f0f17fa266982374700a8a4ce6b2f5a.gz
This commit is contained in:
parent
7df536023b
commit
b1439075c6
83
reader.c
83
reader.c
|
@ -1984,11 +1984,25 @@ static void handle_token_history( int forward, int reset )
|
||||||
static void move_word( int dir, int erase )
|
static void move_word( int dir, int erase )
|
||||||
{
|
{
|
||||||
int end_buff_pos=data->buff_pos;
|
int end_buff_pos=data->buff_pos;
|
||||||
int mode=0;
|
|
||||||
int step = dir?1:-1;
|
int step = dir?1:-1;
|
||||||
|
|
||||||
while( mode < 2 )
|
/*
|
||||||
|
If we are beyond the last character and moving left, start by
|
||||||
|
moving one step, since otehrwise we'll start on the \0, which
|
||||||
|
should be ignored.
|
||||||
|
*/
|
||||||
|
if( !dir && (end_buff_pos == data->buff_len) )
|
||||||
{
|
{
|
||||||
|
if( !end_buff_pos )
|
||||||
|
return;
|
||||||
|
|
||||||
|
end_buff_pos--;
|
||||||
|
}
|
||||||
|
|
||||||
|
while( 1 )
|
||||||
|
{
|
||||||
|
wchar_t c;
|
||||||
|
|
||||||
if( !dir )
|
if( !dir )
|
||||||
{
|
{
|
||||||
if( end_buff_pos == 0 )
|
if( end_buff_pos == 0 )
|
||||||
|
@ -1999,41 +2013,46 @@ static void move_word( int dir, int erase )
|
||||||
if( end_buff_pos == data->buff_len )
|
if( end_buff_pos == data->buff_len )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
end_buff_pos+=step;
|
|
||||||
|
|
||||||
if( end_buff_pos < data->buff_len )
|
c = data->buff[end_buff_pos];
|
||||||
|
|
||||||
|
if( !iswspace( c ) )
|
||||||
{
|
{
|
||||||
switch( mode )
|
break;
|
||||||
{
|
}
|
||||||
case 0:
|
|
||||||
if( iswalnum(data->buff[end_buff_pos] ) )
|
end_buff_pos+=step;
|
||||||
mode++;
|
}
|
||||||
break;
|
|
||||||
|
while( 1 )
|
||||||
case 1:
|
{
|
||||||
if( !iswalnum(data->buff[end_buff_pos] ) )
|
wchar_t c;
|
||||||
{
|
|
||||||
if( !dir )
|
if( !dir )
|
||||||
end_buff_pos -= step;
|
{
|
||||||
mode++;
|
if( end_buff_pos == 0 )
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
/*
|
else
|
||||||
case 2:
|
{
|
||||||
if( !iswspace(data->buff[end_buff_pos] ) )
|
if( end_buff_pos == data->buff_len )
|
||||||
{
|
break;
|
||||||
mode++;
|
|
||||||
if( !dir )
|
|
||||||
end_buff_pos-=step;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( mode==2)
|
c = data->buff[end_buff_pos];
|
||||||
break;
|
|
||||||
|
|
||||||
|
if( !iswalnum( c ) )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Don't gobble the boundary character if it was a
|
||||||
|
whitespace, but do for all other non-alphabetic
|
||||||
|
characters
|
||||||
|
*/
|
||||||
|
if( iswspace( c ) )
|
||||||
|
end_buff_pos -= step;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
end_buff_pos+=step;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( erase )
|
if( erase )
|
||||||
|
|
Loading…
Reference in New Issue
Block a user