@@ -2107,10 +2107,6 @@ fn sort(cx: &mut compositor::Context, args: Args, event: PromptEvent) -> anyhow:
21072107 return Ok ( ( ) ) ;
21082108 }
21092109
2110- sort_impl ( cx, args. has_flag ( "reverse" ) )
2111- }
2112-
2113- fn sort_impl ( cx : & mut compositor:: Context , reverse : bool ) -> anyhow:: Result < ( ) > {
21142110 let scrolloff = cx. editor . config ( ) . scrolloff ;
21152111 let ( view, doc) = current ! ( cx. editor) ;
21162112 let text = doc. text ( ) . slice ( ..) ;
@@ -2126,10 +2122,14 @@ fn sort_impl(cx: &mut compositor::Context, reverse: bool) -> anyhow::Result<()>
21262122 . map ( |fragment| fragment. chunks ( ) . collect ( ) )
21272123 . collect ( ) ;
21282124
2129- fragments. sort_by ( match reverse {
2130- true => |a : & Tendril , b : & Tendril | b. cmp ( a) ,
2131- false => |a : & Tendril , b : & Tendril | a. cmp ( b) ,
2132- } ) ;
2125+ fragments. sort_by (
2126+ match ( args. has_flag ( "insensitive" ) , args. has_flag ( "reverse" ) ) {
2127+ ( true , true ) => |a : & Tendril , b : & Tendril | b. to_lowercase ( ) . cmp ( & a. to_lowercase ( ) ) ,
2128+ ( true , false ) => |a : & Tendril , b : & Tendril | a. to_lowercase ( ) . cmp ( & b. to_lowercase ( ) ) ,
2129+ ( false , true ) => |a : & Tendril , b : & Tendril | b. cmp ( a) ,
2130+ ( false , false ) => |a : & Tendril , b : & Tendril | a. cmp ( b) ,
2131+ } ,
2132+ ) ;
21332133
21342134 let transaction = Transaction :: change (
21352135 doc. text ( ) ,
@@ -3357,6 +3357,12 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
33573357 signature : Signature {
33583358 positionals : ( 0 , Some ( 0 ) ) ,
33593359 flags : & [
3360+ Flag {
3361+ name : "insensitive" ,
3362+ alias : Some ( 'i' ) ,
3363+ doc : "sort the ranges case-insensitively" ,
3364+ ..Flag :: DEFAULT
3365+ } ,
33603366 Flag {
33613367 name : "reverse" ,
33623368 alias : Some ( 'r' ) ,
0 commit comments