Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6777795

Browse files
authored
fix: do not panic when text contains multiple values (#20)
1 parent da31470 commit 6777795

File tree

6 files changed

+21
-7
lines changed

6 files changed

+21
-7
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
token: ${{ secrets.GH_DPRINTBOT_PAT }}
2626

2727
- uses: denoland/setup-deno@v1
28-
- uses: dtolnay/rust-toolchain@stable
28+
- uses: dsherret/rust-toolchain-file@v1
2929

3030
- name: Bump version and tag
3131
env:

.rustfmt.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
max_width = 120
2+
tab_spaces = 2
3+
edition = "2021"

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tracing = ["dprint-core/tracing"]
2626

2727
[dependencies]
2828
anyhow = "1.0.64"
29-
dprint-core = { version = "0.62.0", features = ["formatting"] }
29+
dprint-core = { version = "0.62.1", features = ["formatting"] }
3030
jsonc-parser = { version = "0.21.1" }
3131
serde = { version = "1.0.144", features = ["derive"] }
3232
serde_json = { version = "1.0", optional = true }

dprint.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"**/benches/data"
1313
],
1414
"plugins": [
15-
"https://plugins.dprint.dev/typescript-0.84.2.wasm",
16-
"https://plugins.dprint.dev/json-0.17.1.wasm",
17-
"https://plugins.dprint.dev/markdown-0.15.2.wasm",
15+
"https://plugins.dprint.dev/typescript-0.85.0.wasm",
16+
"https://plugins.dprint.dev/json-0.17.3.wasm",
17+
"https://plugins.dprint.dev/markdown-0.15.3.wasm",
1818
"https://plugins.dprint.dev/toml-0.5.4.wasm",
1919
"https://plugins.dprint.dev/exec-0.3.5.json@d687dda57be0fe9a0088ccdaefa5147649ff24127d8b3ea227536c68ee7abeab"
2020
]

src/format_text.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,15 @@ mod tests {
8989
"Line 1, column 7: Unexpected token\n\n { \"a\":\u{200b}5 }\n ~"
9090
);
9191
}
92+
93+
#[test]
94+
fn no_panic_diagnostic_multiple_values() {
95+
let global_config = GlobalConfiguration::default();
96+
let config = resolve_config(ConfigKeyMap::new(), &global_config).config;
97+
let message = format_text("{},\n", &config).err().unwrap().to_string();
98+
assert_eq!(
99+
message,
100+
"Line 1, column 3: Text cannot contain more than one JSON value\n\n {},"
101+
);
102+
}
92103
}

0 commit comments

Comments
 (0)