@ -1091,27 +1091,18 @@ fn extend_next_long_word_end(cx: &mut Context) {
extend_word_impl ( cx , movement ::move_next_long_word_end )
extend_word_impl ( cx , movement ::move_next_long_word_end )
}
}
fn will_find_char < F > (
fn will_find_char < F > ( cx : & mut Context , search_fn : F , inclusive : bool , extend : bool )
cx : & mut Context ,
where
search_fn : F ,
inclusive : bool ,
extend : bool ,
pseudo_pending : & str ,
) where
F : Fn ( RopeSlice , char , usize , usize , bool ) -> Option < usize > + ' static ,
F : Fn ( RopeSlice , char , usize , usize , bool ) -> Option < usize > + ' static ,
{
{
// TODO: count is reset to 1 before next key so we move it into the closure here.
// TODO: count is reset to 1 before next key so we move it into the closure here.
// Would be nice to carry over.
// Would be nice to carry over.
let count = cx . count ( ) ;
let count = cx . count ( ) ;
cx . editor . pseudo_pending = Some ( pseudo_pending . to_string ( ) ) ;
// need to wait for next key
// need to wait for next key
// TODO: should this be done by grapheme rather than char? For example,
// TODO: should this be done by grapheme rather than char? For example,
// we can't properly handle the line-ending CRLF case here in terms of char.
// we can't properly handle the line-ending CRLF case here in terms of char.
cx . on_next_key ( move | cx , event | {
cx . on_next_key ( move | cx , event | {
cx . editor . pseudo_pending = None ;
let ch = match event {
let ch = match event {
KeyEvent {
KeyEvent {
code : KeyCode ::Enter ,
code : KeyCode ::Enter ,
@ -1214,35 +1205,35 @@ fn find_prev_char_impl(
}
}
fn find_till_char ( cx : & mut Context ) {
fn find_till_char ( cx : & mut Context ) {
will_find_char ( cx , find_next_char_impl , false , false , "t" )
will_find_char ( cx , find_next_char_impl , false , false )
}
}
fn find_next_char ( cx : & mut Context ) {
fn find_next_char ( cx : & mut Context ) {
will_find_char ( cx , find_next_char_impl , true , false , "f" )
will_find_char ( cx , find_next_char_impl , true , false )
}
}
fn extend_till_char ( cx : & mut Context ) {
fn extend_till_char ( cx : & mut Context ) {
will_find_char ( cx , find_next_char_impl , false , true , "t" )
will_find_char ( cx , find_next_char_impl , false , true )
}
}
fn extend_next_char ( cx : & mut Context ) {
fn extend_next_char ( cx : & mut Context ) {
will_find_char ( cx , find_next_char_impl , true , true , "f" )
will_find_char ( cx , find_next_char_impl , true , true )
}
}
fn till_prev_char ( cx : & mut Context ) {
fn till_prev_char ( cx : & mut Context ) {
will_find_char ( cx , find_prev_char_impl , false , false , "T" )
will_find_char ( cx , find_prev_char_impl , false , false )
}
}
fn find_prev_char ( cx : & mut Context ) {
fn find_prev_char ( cx : & mut Context ) {
will_find_char ( cx , find_prev_char_impl , true , false , "F" )
will_find_char ( cx , find_prev_char_impl , true , false )
}
}
fn extend_till_prev_char ( cx : & mut Context ) {
fn extend_till_prev_char ( cx : & mut Context ) {
will_find_char ( cx , find_prev_char_impl , false , true , "T" )
will_find_char ( cx , find_prev_char_impl , false , true )
}
}
fn extend_prev_char ( cx : & mut Context ) {
fn extend_prev_char ( cx : & mut Context ) {
will_find_char ( cx , find_prev_char_impl , true , true , "F" )
will_find_char ( cx , find_prev_char_impl , true , true )
}
}
fn repeat_last_motion ( cx : & mut Context ) {
fn repeat_last_motion ( cx : & mut Context ) {
@ -4392,7 +4383,6 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
cx . on_next_key ( move | cx , event | {
cx . on_next_key ( move | cx , event | {
cx . editor . autoinfo = None ;
cx . editor . autoinfo = None ;
cx . editor . pseudo_pending = None ;
if let Some ( ch ) = event . char ( ) {
if let Some ( ch ) = event . char ( ) {
let textobject = move | editor : & mut Editor | {
let textobject = move | editor : & mut Editor | {
let ( view , doc ) = current ! ( editor ) ;
let ( view , doc ) = current ! ( editor ) ;
@ -4441,11 +4431,11 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
}
}
} ) ;
} ) ;
if let Some ( ( title , abbrev ) ) = match objtype {
let title = match objtype {
textobject ::TextObject ::Inside = > Some ( ( "Match inside" , "mi" ) ) ,
textobject ::TextObject ::Inside = > "Match inside" ,
textobject ::TextObject ::Around = > Some ( ( "Match around" , "ma" ) ) ,
textobject ::TextObject ::Around = > "Match around" ,
_ = > return ,
_ = > return ,
} {
} ;
let help_text = [
let help_text = [
( "w" , "Word" ) ,
( "w" , "Word" ) ,
( "W" , "WORD" ) ,
( "W" , "WORD" ) ,
@ -4466,8 +4456,6 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
. map ( | ( col1 , col2 ) | ( col1 . to_string ( ) , col2 . to_string ( ) ) )
. map ( | ( col1 , col2 ) | ( col1 . to_string ( ) , col2 . to_string ( ) ) )
. collect ( ) ,
. collect ( ) ,
) ) ;
) ) ;
cx . editor . pseudo_pending = Some ( abbrev . to_string ( ) ) ;
} ;
}
}
fn surround_add ( cx : & mut Context ) {
fn surround_add ( cx : & mut Context ) {