@@ -347,9 +347,11 @@ fn calculate_replacement_range(
347347 closing : & ClosingBrace ,
348348) -> Range {
349349 // Start position: move back by the length of the partial text
350- let start_col = position. character . saturating_sub ( u32:: try_from ( partial_len) . unwrap_or ( 0 ) ) ;
350+ let start_col = position
351+ . character
352+ . saturating_sub ( u32:: try_from ( partial_len) . unwrap_or ( 0 ) ) ;
351353 let start = Position :: new ( position. line , start_col) ;
352-
354+
353355 // End position: include auto-paired } if present
354356 let mut end_col = position. character ;
355357 if matches ! ( closing, ClosingBrace :: PartialClose ) {
@@ -360,7 +362,7 @@ fn calculate_replacement_range(
360362 }
361363 }
362364 let end = Position :: new ( position. line , end_col) ;
363-
365+
364366 Range :: new ( start, end)
365367}
366368
@@ -382,15 +384,10 @@ fn generate_tag_name_completions(
382384 } ;
383385
384386 let mut completions = Vec :: new ( ) ;
385-
387+
386388 // Calculate the replacement range for all completions
387- let replacement_range = calculate_replacement_range (
388- position,
389- line_text,
390- cursor_offset,
391- partial. len ( ) ,
392- closing,
393- ) ;
389+ let replacement_range =
390+ calculate_replacement_range ( position, line_text, cursor_offset, partial. len ( ) , closing) ;
394391
395392 // First, check if we should suggest end tags
396393 // If partial starts with "end", prioritize end tags
@@ -420,7 +417,7 @@ fn generate_tag_name_completions(
420417 kind : Some ( CompletionItemKind :: KEYWORD ) ,
421418 detail : Some ( format ! ( "End tag for {opener_name}" ) ) ,
422419 text_edit : Some ( tower_lsp_server:: lsp_types:: CompletionTextEdit :: Edit (
423- TextEdit :: new ( replacement_range, insert_text. clone ( ) )
420+ TextEdit :: new ( replacement_range, insert_text. clone ( ) ) ,
424421 ) ) ,
425422 insert_text_format : Some ( InsertTextFormat :: PLAIN_TEXT ) ,
426423 filter_text : Some ( end_tag. name . clone ( ) ) ,
@@ -494,7 +491,7 @@ fn generate_tag_name_completions(
494491 detail : Some ( format ! ( "from {}" , tag. library( ) ) ) ,
495492 documentation : tag. doc ( ) . map ( |doc| Documentation :: String ( doc. clone ( ) ) ) ,
496493 text_edit : Some ( tower_lsp_server:: lsp_types:: CompletionTextEdit :: Edit (
497- TextEdit :: new ( replacement_range, insert_text. clone ( ) )
494+ TextEdit :: new ( replacement_range, insert_text. clone ( ) ) ,
498495 ) ) ,
499496 insert_text_format : Some ( insert_format) ,
500497 filter_text : Some ( tag. name ( ) . clone ( ) ) ,
@@ -543,12 +540,12 @@ fn generate_argument_completions(
543540 if arg. name . starts_with ( partial) {
544541 let mut insert_text = arg. name . clone ( ) ;
545542
546- // Add closing if needed
547- match closing {
548- ClosingBrace :: None => insert_text. push_str ( " %}" ) ,
549- ClosingBrace :: PartialClose => insert_text. push_str ( " %" ) ,
550- ClosingBrace :: FullClose => { } // No closing needed
551- }
543+ // Add closing if needed
544+ match closing {
545+ ClosingBrace :: None => insert_text. push_str ( " %}" ) ,
546+ ClosingBrace :: PartialClose => insert_text. push_str ( " %" ) ,
547+ ClosingBrace :: FullClose => { } // No closing needed
548+ }
552549
553550 completions. push ( CompletionItem {
554551 label : arg. name . clone ( ) ,
@@ -850,15 +847,8 @@ mod tests {
850847 closing : ClosingBrace :: None ,
851848 } ;
852849
853- let completions = generate_template_completions (
854- & context,
855- None ,
856- None ,
857- false ,
858- Position :: new ( 0 , 0 ) ,
859- "" ,
860- 0 ,
861- ) ;
850+ let completions =
851+ generate_template_completions ( & context, None , None , false , Position :: new ( 0 , 0 ) , "" , 0 ) ;
862852
863853 assert ! ( completions. is_empty( ) ) ;
864854 }
@@ -969,5 +959,4 @@ mod tests {
969959 }
970960 ) ;
971961 }
972-
973962}
0 commit comments