File tree Expand file tree Collapse file tree 1 file changed +29
-7
lines changed
Expand file tree Collapse file tree 1 file changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -614,17 +614,39 @@ impl GlobalState<'_> {
614614 & mut self ,
615615 params : FoldingRangeParams ,
616616 ) -> anyhow:: Result < Option < Vec < FoldingRange > > > {
617+ let encoding = self . client_capabilities . negotiated_encoding ( ) ;
618+ let line_folding_only = self . client_capabilities . line_folding_only ( ) ;
617619 let document = self . document ( params. text_document ) ?;
618620 Ok ( Some (
619621 document
620622 . folding_ranges ( )
621- . map ( |folding_range| FoldingRange {
622- start_line : folding_range. start . line_zero_based ( ) as u32 ,
623- end_line : folding_range. end . line_zero_based ( ) as u32 ,
624- kind : Some ( folding_range. kind ) ,
625- start_character : None ,
626- end_character : None ,
627- collapsed_text : None ,
623+ . map ( |folding_range| {
624+ let ( start_line, start_character, end_line, end_character) =
625+ if line_folding_only {
626+ (
627+ folding_range. start . line_zero_based ( ) as u32 ,
628+ None ,
629+ folding_range. end . line_zero_based ( ) as u32 ,
630+ None ,
631+ )
632+ } else {
633+ let start = Self :: to_position ( encoding, folding_range. start ) ;
634+ let end = Self :: to_position ( encoding, folding_range. end ) ;
635+ (
636+ start. line ,
637+ Some ( start. character ) ,
638+ end. line ,
639+ Some ( end. character ) ,
640+ )
641+ } ;
642+ FoldingRange {
643+ start_line,
644+ end_line,
645+ start_character,
646+ end_character,
647+ kind : Some ( folding_range. kind ) ,
648+ collapsed_text : None ,
649+ }
628650 } )
629651 . collect ( ) ,
630652 ) )
You can’t perform that action at this time.
0 commit comments