Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 00b1913

Browse files
committed
Add tests
1 parent f5a2f4d commit 00b1913

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

rls/src/actions/format.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ mod tests {
214214
use super::*;
215215
use crate::config::FmtConfig;
216216
use lsp_types::{Position, Range, TextEdit};
217+
use rustfmt_nightly::FileLines;
218+
use std::str::FromStr;
217219

218220
#[test]
219221
fn calc_text_edits() {
@@ -247,4 +249,20 @@ mod tests {
247249
vec![(0, 0, 1, 0, "struct Upper;\n"), (2, 0, 3, 0, "struct Lower;\n")],
248250
);
249251
}
252+
253+
#[test]
254+
fn no_empty_file_lines() {
255+
let config_with_lines = {
256+
let mut config = Config::default();
257+
config.set().file_lines(
258+
FileLines::from_str(r#"[{ "file": "stdin", "range": [0, 5] }]"#).unwrap(),
259+
);
260+
config
261+
};
262+
let args = rustfmt_args(&config_with_lines, Path::new("dummy"));
263+
assert!(args.join(" ").find("--file-lines").is_some());
264+
265+
let args = rustfmt_args(&Config::default(), Path::new("dummy"));
266+
assert_eq!(args.join(" ").find("--file-lines"), None);
267+
}
250268
}

0 commit comments

Comments
 (0)