File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ impl Formatter {
166166 // - must contain at least one new line character between `extends_name` and optional doc comment
167167 // - may contain multiple doc comment lines that starts with `##` and ends with a new line character
168168 let re = RegexBuilder :: new (
169- r#"(?P<extends_line>^extends )(?P<extends_name>([a-zA-Z0-9]+|".*?"))\n+(?P<doc>(?:^##.*\n)*)(?P<EOF>\z)?"# ,
169+ r#"(?P<extends_line>^extends )(?P<extends_name>([a-zA-Z0-9]+|".*?"))\n+(?P<doc>(?:^##.*\n)*)\n* (?P<EOF>\z)?"# ,
170170 )
171171 . multi_line ( true )
172172 . build ( )
@@ -175,11 +175,7 @@ impl Formatter {
175175 self . regex_replace_all_outside_strings ( re, |caps : & regex:: Captures | {
176176 let extends_line = caps. name ( "extends_line" ) . unwrap ( ) . as_str ( ) ;
177177 let extends_name = caps. name ( "extends_name" ) . unwrap ( ) . as_str ( ) ;
178- let doc = caps
179- . name ( "doc" )
180- . map ( |m| m. as_str ( ) )
181- . unwrap_or_default ( )
182- . trim_end ( ) ; // remove last new line from doc comment because we add a new line manually
178+ let doc = caps. name ( "doc" ) . map ( |m| m. as_str ( ) ) . unwrap_or_default ( ) ;
183179 // insert new line only if we are not at the end of file
184180 let blank_new_line = if caps. name ( "EOF" ) . is_some ( ) { "" } else { "\n " } ;
185181
Original file line number Diff line number Diff line change @@ -3,11 +3,13 @@ extends CharacterBody2D
33## A brief description of the class's role and functionality.
44##
55## The description of script
6+
67class_name Player
78extends CharacterBody2D
89## A brief description of the class's role and functionality.
910##
1011## The description of script
12+
1113class_name Player
1214extends CharacterBody2D
1315## A brief description of the class's role and functionality.
@@ -22,3 +24,8 @@ extends CharacterBody2D
2224## The description of script
2325
2426var a = 10
27+ class_name Player
28+ extends CharacterBody2D
29+ ## A brief description of the class's role and functionality.
30+
31+ var a = 10
Original file line number Diff line number Diff line change @@ -21,3 +21,7 @@ extends CharacterBody2D
2121## The description of script
2222
2323var a = 10
24+ class_name Player
25+ extends CharacterBody2D
26+ ## A brief description of the class's role and functionality.
27+ var a = 10
You can’t perform that action at this time.
0 commit comments