Skip to content

Commit e046e67

Browse files
feat(oxc_codegen): support configure initial indent when using oxc_codegen (#13091)
1 parent 74fb6c9 commit e046e67

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

crates/oxc_codegen/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ impl<'a> Codegen<'a> {
197197
pub fn build(mut self, program: &Program<'a>) -> CodegenReturn {
198198
self.quote = if self.options.single_quote { Quote::Single } else { Quote::Double };
199199
self.source_text = Some(program.source_text);
200+
self.indent = self.options.initial_indent;
200201
self.code.reserve(program.source_text.len());
201202
self.build_comments(&program.comments);
202203
if let Some(path) = &self.options.source_map_path {

crates/oxc_codegen/src/options.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ pub struct CodegenOptions {
3838
///
3939
/// Default is `1`.
4040
pub indent_width: usize,
41+
42+
/// Initial indentation level.
43+
pub initial_indent: u32,
4144
}
4245

4346
impl Default for CodegenOptions {
@@ -49,6 +52,7 @@ impl Default for CodegenOptions {
4952
source_map_path: None,
5053
indent_char: IndentChar::default(),
5154
indent_width: DEFAULT_INDENT_WIDTH,
55+
initial_indent: 0,
5256
}
5357
}
5458
}
@@ -63,6 +67,7 @@ impl CodegenOptions {
6367
source_map_path: None,
6468
indent_char: IndentChar::default(),
6569
indent_width: DEFAULT_INDENT_WIDTH,
70+
initial_indent: 0,
6671
}
6772
}
6873

0 commit comments

Comments
 (0)