3
3
use dprint_core:: formatting:: conditions:: * ;
4
4
use dprint_core:: formatting:: ir_helpers:: SingleLineOptions ;
5
5
use dprint_core:: formatting:: * ;
6
+ use dprint_core_macros:: sc;
6
7
use std:: cell:: Cell ;
7
8
use std:: rc:: Rc ;
8
9
use taplo:: rowan:: NodeOrToken ;
@@ -64,7 +65,7 @@ fn gen_node_with_inner<'a>(node: SyntaxElement, context: &mut Context<'a>, inner
64
65
SyntaxKind :: COMMENT => Ok ( gen_comment ( token, context) ) ,
65
66
SyntaxKind :: MULTI_LINE_STRING | SyntaxKind :: MULTI_LINE_STRING_LITERAL => {
66
67
let mut items = PrintItems :: new ( ) ;
67
- items. push_str ( "" ) ;
68
+ items. push_force_current_line_indentation ( ) ;
68
69
items. extend ( ir_helpers:: gen_from_raw_string ( token. text ( ) . trim ( ) ) ) ;
69
70
Ok ( items)
70
71
}
@@ -178,14 +179,14 @@ fn gen_inline_table<'a>(node: SyntaxNode, context: &mut Context<'a>) -> PrintIte
178
179
ensure_all_kind ( values. clone ( ) , SyntaxKind :: ENTRY ) ?;
179
180
180
181
let mut items = PrintItems :: new ( ) ;
181
- items. push_str ( "{" ) ;
182
+ items. push_sc ( sc ! ( "{" ) ) ;
182
183
let mut had_item = false ;
183
184
for ( i, value) in values. enumerate ( ) {
184
- items. push_str ( if i > 0 { ", " } else { " " } ) ;
185
+ items. push_sc ( if i > 0 { sc ! ( ", " ) } else { sc ! ( " " ) } ) ;
185
186
items. extend ( gen_node ( value. into ( ) , context) ) ;
186
187
had_item = true ;
187
188
}
188
- items. push_str ( if had_item { " }" } else { "}" } ) ;
189
+ items. push_sc ( if had_item { sc ! ( " }" ) } else { sc ! ( "}" ) } ) ;
189
190
190
191
// the comment seems to be stored as the last child of an inline table, so check for it here
191
192
if let Some ( NodeOrToken :: Token ( token) ) = node. children_with_tokens ( ) . last ( ) {
@@ -209,7 +210,7 @@ fn gen_entry<'a>(node: SyntaxNode, context: &mut Context<'a>) -> PrintItemsResul
209
210
let mut items = PrintItems :: new ( ) ;
210
211
211
212
items. extend ( gen_node ( key. into ( ) , context) ) ;
212
- items. push_str ( " = " ) ;
213
+ items. push_sc ( sc ! ( " = " ) ) ;
213
214
items. extend ( gen_node ( value. into ( ) , context) ) ;
214
215
215
216
Ok ( items)
@@ -237,19 +238,19 @@ fn gen_table_header<'a>(node: SyntaxNode, context: &mut Context<'a>) -> PrintIte
237
238
// Spec: Naming rules for tables are the same as for keys
238
239
let key = get_child_with_kind ( node. clone ( ) , SyntaxKind :: KEY ) ?;
239
240
let mut items = PrintItems :: new ( ) ;
240
- items. push_str ( "[" ) ;
241
+ items. push_sc ( sc ! ( "[" ) ) ;
241
242
items. extend ( gen_node ( key. into ( ) , context) ) ;
242
- items. push_str ( "]" ) ;
243
+ items. push_sc ( sc ! ( "]" ) ) ;
243
244
Ok ( items)
244
245
}
245
246
246
247
fn gen_table_array_header < ' a > ( node : SyntaxNode , context : & mut Context < ' a > ) -> PrintItemsResult {
247
248
// Spec: Naming rules for tables are the same as for keys
248
249
let key = get_child_with_kind ( node. clone ( ) , SyntaxKind :: KEY ) ?;
249
250
let mut items = PrintItems :: new ( ) ;
250
- items. push_str ( "[[" ) ;
251
+ items. push_sc ( sc ! ( "[[" ) ) ;
251
252
items. extend ( gen_node ( key. into ( ) , context) ) ;
252
- items. push_str ( "]]" ) ;
253
+ items. push_sc ( sc ! ( "]]" ) ) ;
253
254
Ok ( items)
254
255
}
255
256
0 commit comments