@@ -445,7 +445,8 @@ pub(crate) fn parse_astro_embedded_script(
445445 settings : & Settings ,
446446) -> Option < ( EmbeddedSnippet < JsLanguage > , DocumentFileSource ) > {
447447 let content = element. content_token ( ) ?;
448- let file_source = JsFileSource :: ts ( ) . with_embedding_kind ( EmbeddingKind :: AstroFrontmatter ) ;
448+ let file_source =
449+ JsFileSource :: ts ( ) . with_embedding_kind ( EmbeddingKind :: Astro { frontmatter : true } ) ;
449450 let document_file_source = DocumentFileSource :: Js ( file_source) ;
450451 let options = settings. parse_options :: < JsLanguage > ( path, & document_file_source) ;
451452 let parse = parse_js_with_offset_and_cache (
@@ -493,7 +494,7 @@ pub(crate) fn parse_embedded_script(
493494 }
494495 file_source
495496 } else if html_file_source. is_astro ( ) {
496- JsFileSource :: ts ( ) . with_embedding_kind ( EmbeddingKind :: Astro )
497+ JsFileSource :: ts ( ) . with_embedding_kind ( EmbeddingKind :: Astro { frontmatter : false } )
497498 } else {
498499 let is_module = element. is_javascript_module ( ) . unwrap_or_default ( ) ;
499500 if is_module {
@@ -672,8 +673,8 @@ fn format_embedded(
672673 let mut iter = embedded_nodes. iter ( ) ;
673674 let node = iter. find ( |node| node. range == range) ?;
674675
675- let wrap_document = |document : Document , is_astro_frontmatter : bool | {
676- if indent_script_and_style && !is_astro_frontmatter {
676+ let wrap_document = |document : Document , should_indent : bool | {
677+ if indent_script_and_style && should_indent {
677678 let elements = vec ! [
678679 FormatElement :: Line ( LineMode :: Hard ) ,
679680 FormatElement :: Tag ( Tag :: StartIndent ) ,
@@ -701,7 +702,7 @@ fn format_embedded(
701702
702703 Some ( wrap_document (
703704 formatted. into_document ( ) ,
704- file_source. as_embedding_kind ( ) == & EmbeddingKind :: AstroFrontmatter ,
705+ ! file_source. as_embedding_kind ( ) . is_astro_frontmatter ( ) ,
705706 ) )
706707 }
707708 DocumentFileSource :: Json ( _) => {
@@ -710,14 +711,14 @@ fn format_embedded(
710711 let node = node. node . clone ( ) . embedded_syntax :: < JsonLanguage > ( ) . clone ( ) ;
711712 let formatted =
712713 biome_json_formatter:: format_node_with_offset ( json_options, & node) . ok ( ) ?;
713- Some ( wrap_document ( formatted. into_document ( ) , false ) )
714+ Some ( wrap_document ( formatted. into_document ( ) , true ) )
714715 }
715716 DocumentFileSource :: Css ( _) => {
716717 let css_options = settings. format_options :: < CssLanguage > ( biome_path, & node. source ) ;
717718 let node = node. node . clone ( ) . embedded_syntax :: < CssLanguage > ( ) ;
718719 let formatted =
719720 biome_css_formatter:: format_node_with_offset ( css_options, & node) . ok ( ) ?;
720- Some ( wrap_document ( formatted. into_document ( ) , false ) )
721+ Some ( wrap_document ( formatted. into_document ( ) , true ) )
721722 }
722723 _ => None ,
723724 }
0 commit comments