File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use crate :: { Document , FormattedLine , LineType } ;
22
3+ #[ cfg( not( windows) ) ]
4+ const LINEBREAK : & str = "\n " ;
5+ #[ cfg( windows) ]
6+ const LINEBREAK : & str = "\r \n " ;
7+
38#[ derive( Debug , Eq , PartialEq ) ]
49enum Action {
510 Start ,
@@ -75,11 +80,11 @@ pub fn format_to_string(document: &Document) -> String {
7580
7681 for block in document. blocks . iter ( ) {
7782 if last_action == Action :: InsertBodyText {
78- formatted += " \n " ;
83+ formatted += LINEBREAK ;
7984 }
8085
8186 formatted += & format ! (
82- "{indenting}{header}\n \n " ,
87+ "{indenting}{header}{LINEBREAK}{LINEBREAK} " ,
8388 indenting = " " . repeat( block. header. num_indent( ) ) ,
8489 header = block. header. contents
8590 ) ;
@@ -95,12 +100,12 @@ pub fn format_to_string(document: &Document) -> String {
95100 }
96101
97102 last_action = if formatted_line. is_empty ( ) {
98- formatted += " \n " ;
103+ formatted += LINEBREAK ;
99104
100105 Action :: InsertBlankLine
101106 } else {
102107 formatted += & format ! (
103- "{indenting}{line}\n " ,
108+ "{indenting}{line}{LINEBREAK} " ,
104109 indenting = " " . repeat( formatted_line. num_indent( ) ) ,
105110 line = formatted_line. contents
106111 ) ;
You can’t perform that action at this time.
0 commit comments