@@ -261,9 +261,10 @@ pub fn insert_import_edit_with_forced_import_format(
261261 export_name,
262262 display_text. clone ( ) ,
263263 module_name_to_import. as_str ( ) ,
264- ) {
265- return edit;
266- }
264+ )
265+ {
266+ return edit;
267+ }
267268 let position = if let Some ( first_stmt) = ast. body . iter ( ) . find ( |stmt| !is_docstring_stmt ( stmt) ) {
268269 first_stmt. range ( ) . start ( )
269270 } else {
@@ -313,26 +314,27 @@ fn try_extend_existing_from_import(
313314) -> Option < ImportEdit > {
314315 for stmt in & ast. body {
315316 if let Stmt :: ImportFrom ( import_from) = stmt
316- && import_from_module_name ( import_from) == target_module_name {
317- if import_from
318- . names
319- . iter ( )
320- . any ( |alias| alias. asname . is_none ( ) && alias. name . as_str ( ) == export_name)
321- {
322- // Already imported; don't propose a duplicate edit.
323- return None ;
324- }
325- if let Some ( last_alias) = import_from. names . last ( ) {
326- let position = last_alias. range . end ( ) ;
327- let insert_text = format ! ( ", {}" , export_name) ;
328- return Some ( ImportEdit {
329- position,
330- insert_text,
331- display_text,
332- module_name : module_name. to_owned ( ) ,
333- } ) ;
334- }
317+ && import_from_module_name ( import_from) == target_module_name
318+ {
319+ if import_from
320+ . names
321+ . iter ( )
322+ . any ( |alias| alias. asname . is_none ( ) && alias. name . as_str ( ) == export_name)
323+ {
324+ // Already imported; don't propose a duplicate edit.
325+ return None ;
335326 }
327+ if let Some ( last_alias) = import_from. names . last ( ) {
328+ let position = last_alias. range . end ( ) ;
329+ let insert_text = format ! ( ", {}" , export_name) ;
330+ return Some ( ImportEdit {
331+ position,
332+ insert_text,
333+ display_text,
334+ module_name : module_name. to_owned ( ) ,
335+ } ) ;
336+ }
337+ }
336338 }
337339 None
338340}
0 commit comments