@@ -337,7 +337,11 @@ pub fn server(experimental: bool) {
337337#[ derive( Debug ) ]
338338pub struct DebugError ;
339339
340- pub fn index ( paths : Option < & [ PathBuf ] > , print_items : bool ) -> Result < ( ) , DebugError > {
340+ pub fn index (
341+ paths : Option < & [ PathBuf ] > ,
342+ recursive : bool ,
343+ print_items : bool ,
344+ ) -> Result < ( ) , DebugError > {
341345 let root: Vec < PathBuf > = vec ! [ "." . into( ) ] ;
342346 let paths = paths. unwrap_or ( & root) ;
343347
@@ -364,28 +368,30 @@ pub fn index(paths: Option<&[PathBuf]>, print_items: bool) -> Result<(), DebugEr
364368 } )
365369 . collect :: < Result < Vec < _ > , _ > > ( ) ?
366370 {
367- let text = std :: fs :: read_to_string ( & path) . map_err ( |err| {
371+ let rope = utils :: read_to_rope ( & path) . map_err ( |err| {
368372 error ( & format ! ( "failed to index: {}" , path. display( ) ) ) ;
369373 eprintln ! ( "{err}" ) ;
370374 DebugError
371375 } ) ?;
372376
373377 // Only time the indexing operation, not the I/O
374378 let start = std:: time:: Instant :: now ( ) ;
375- let symbols = index:: index ( & text) ;
379+ let tree = tree:: parse_rope ( & rope, None ) ;
380+ let symbols = index:: index ( tree. root_node ( ) , & rope, recursive) ;
376381 let elapsed = start. elapsed ( ) ;
377382
378- total_bytes += text. len ( ) ;
383+ let bytes = rope. len_bytes ( ) ;
384+ total_bytes += bytes;
379385 total_files += 1 ;
380386 total_symbols += symbols. len ( ) ;
381387 total_time += elapsed;
382388
383389 eprintln ! (
384390 "{} ({}, {} ms, {}/s)" ,
385391 style( path. display( ) . to_string( ) ) . bold( ) . blue( ) ,
386- utils:: human_bytes( text . len ( ) as f64 ) ,
392+ utils:: human_bytes( bytes as f64 ) ,
387393 elapsed. as_millis( ) ,
388- utils:: human_bytes( text . len ( ) as f64 / elapsed. as_secs_f64( ) ) ,
394+ utils:: human_bytes( bytes as f64 / elapsed. as_secs_f64( ) ) ,
389395 ) ;
390396
391397 if print_items {
0 commit comments