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

Commit

Permalink
Pass --file-lines to rustfmt only if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Jun 24, 2019
1 parent 36def18 commit df7fcf9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions rls/src/actions/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,13 @@ fn rustfmt_args(config: &Config, config_path: &Path) -> Vec<String> {
"--quiet".into(),
];

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

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

0 comments on commit df7fcf9

Please sign in to comment.