File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed
Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -365,8 +365,21 @@ impl Formatter {
365365 if last_comment_is_doc_comment {
366366 let mut comment_node_index = m. captures . len ( ) - 2 ;
367367
368+ let first_comment_node = m. captures [ 1 ] . node ;
369+ let first_comment_is_inline_comment =
370+ first_comment_node. start_position ( ) . row
371+ == first_node. start_position ( ) . row ;
372+ // ignore n first nodes when searching for the first docstring comment node
373+ // in case if the first comment is an inline comment we ignore
374+ // two nodes: first statement node and inline comment node
375+ // otherwise we ignore only the first statement node
376+ let mut amount_of_nodes_to_ignore = 1 ;
377+ if first_comment_is_inline_comment {
378+ amount_of_nodes_to_ignore += 1 ;
379+ }
380+
368381 // find first documentation comment node
369- while comment_node_index > 2
382+ while comment_node_index > amount_of_nodes_to_ignore
370383 && m. captures [ comment_node_index - 1 ] . node . start_position ( ) . row
371384 == m. captures [ comment_node_index] . node . start_position ( ) . row - 1
372385 {
Original file line number Diff line number Diff line change @@ -6,6 +6,12 @@ func test2() -> void:
66 pass
77
88
9+ # Multiline docstring
10+ # another line
11+ func test2 () -> void :
12+ pass
13+
14+
915var a # case 2
1016
1117
Original file line number Diff line number Diff line change 44func test2 () -> void :
55 pass
66
7+ # Multiline docstring
8+ # another line
9+ func test2 () -> void :
10+ pass
11+
712var a # case 2
813
914func test2 () -> void :
You can’t perform that action at this time.
0 commit comments