Skip to content

Commit 65e1dbc

Browse files
committed
fix(formatter): should not add a hard space before function body
1 parent 9097167 commit 65e1dbc

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

crates/oxc_formatter/src/formatter/builders.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,7 @@ pub fn soft_line_indent_or_space<'ast>(content: &impl Format<'ast>) -> BlockInde
14521452
/// # }
14531453
/// ```
14541454
#[inline]
1455+
#[expect(unused)]
14551456
pub fn soft_line_indent_or_hard_space<'ast>(content: &impl Format<'ast>) -> BlockIndent<'_, 'ast> {
14561457
BlockIndent { content: Argument::new(content), mode: IndentMode::HardSpace }
14571458
}

crates/oxc_formatter/src/write/arrow_function_expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl<'a, 'b> FormatJsArrowFunctionExpression<'a, 'b> {
205205
[
206206
formatted_signature,
207207
group(&format_args!(
208-
soft_line_indent_or_hard_space(&format_with(|f| {
208+
soft_line_indent_or_space(&format_with(|f| {
209209
if should_add_parens {
210210
write!(f, if_group_fits_on_line(&"("));
211211
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let object = {
2+
id: '_files.pickFolderAndOpen',
3+
handler: (
4+
accessor: ServicesAccessor,
5+
options: { forceNewWindow: boolean }
6+
) => accessor.get(IFileDialogService).pickFolderAndOpen(options)
7+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
source: crates/oxc_formatter/tests/fixtures/mod.rs
3+
---
4+
==================== Input ====================
5+
let object = {
6+
id: '_files.pickFolderAndOpen',
7+
handler: (
8+
accessor: ServicesAccessor,
9+
options: { forceNewWindow: boolean }
10+
) => accessor.get(IFileDialogService).pickFolderAndOpen(options)
11+
}
12+
==================== Output ====================
13+
------------------
14+
{ printWidth: 80 }
15+
------------------
16+
let object = {
17+
id: "_files.pickFolderAndOpen",
18+
handler: (accessor: ServicesAccessor, options: { forceNewWindow: boolean }) =>
19+
accessor.get(IFileDialogService).pickFolderAndOpen(options),
20+
};
21+
22+
-------------------
23+
{ printWidth: 100 }
24+
-------------------
25+
let object = {
26+
id: "_files.pickFolderAndOpen",
27+
handler: (accessor: ServicesAccessor, options: { forceNewWindow: boolean }) =>
28+
accessor.get(IFileDialogService).pickFolderAndOpen(options),
29+
};
30+
31+
===================== End =====================

0 commit comments

Comments
 (0)