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

Commit 4262210

Browse files
committed
Pass --file-lines to rustfmt only if specified
1 parent a47fb6e commit 4262210

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

rls/src/actions/format.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,13 @@ fn rustfmt_args(config: &Config, config_path: &Path) -> Vec<String> {
195195
"--quiet".into(),
196196
];
197197

198-
args.push("--file-lines".into());
199-
let file_lines_json = config.file_lines().to_json_spans();
200-
let lines: String = serde_json::to_string(&file_lines_json).unwrap();
201-
args.push(lines);
198+
// Otherwise --file-lines [] are treated as no lines rather than FileLines::all()
199+
if config.file_lines().files().count() > 0 {
200+
args.push("--file-lines".into());
201+
let file_lines_json = config.file_lines().to_json_spans();
202+
let lines = serde_json::to_string(&file_lines_json).unwrap();
203+
args.push(lines);
204+
}
202205

203206
args.push("--config-path".into());
204207
args.push(config_path.to_str().map(ToOwned::to_owned).unwrap());

0 commit comments

Comments
 (0)