Skip to content

Commit 74dfc7a

Browse files
3timeslazykamadorueda
authored andcommitted
Allow tabs and spaces
1 parent e518b23 commit 74dfc7a

File tree

8 files changed

+59
-1
lines changed

8 files changed

+59
-1
lines changed

src/alejandra/src/builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub(crate) struct BuildCtx {
2222
pub pos_old: crate::position::Position,
2323
pub path: String,
2424
pub vertical: bool,
25+
pub indent: String,
2526
}
2627

2728
pub(crate) fn build(
@@ -99,7 +100,7 @@ fn build_step(
99100
add_token(
100101
builder,
101102
rnix::SyntaxKind::TOKEN_WHITESPACE,
102-
&format!("{0:<1$}", "", 2 * build_ctx.indentation),
103+
&build_ctx.indent.repeat(build_ctx.indentation),
103104
);
104105
}
105106
}

src/alejandra/src/format.rs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub fn in_memory(
3939
path,
4040
pos_old: crate::position::Position::default(),
4141
vertical: true,
42+
indent,
4243
};
4344

4445
let after = crate::builder::build(&mut build_ctx, ast.node().into())
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
foo =
3+
bar:
4+
baz:
5+
fnbody;
6+
}
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
foo = bar: baz:
3+
fnbody;
4+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
a = rec {
3+
a = {
4+
a = rec {
5+
a = {
6+
a = rec {a = {a = rec {a = {a = rec {a = {};};};};};};
7+
};
8+
};
9+
};
10+
};
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
a = rec {
3+
a = {
4+
a = rec {
5+
a = {
6+
a = rec {a = {a = rec {a = {a = rec {a = {};};};};};};
7+
};
8+
};
9+
};
10+
};
11+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
# over indented
3+
1
4+
# under indented
5+
2
6+
# no indentation
7+
[1 2]
8+
[
9+
1 2 3
10+
]
11+
]
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
# over indented
3+
1
4+
# under indented
5+
2
6+
# no indentation
7+
[1 2]
8+
[
9+
1
10+
2
11+
3
12+
]
13+
]

0 commit comments

Comments
 (0)