Skip to content

Commit

Permalink
Pass lang_conf with language so they're Some/None together
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Sep 28, 2023
1 parent 00f7ef8 commit 40403b2
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ fn diff_file_content(
};

let language = guess(guess_path, guess_src, overrides);
let lang_config = language.map(tsp::from_language);
let lang_config = language.map(|lang| (lang.clone(), tsp::from_language(lang)));

if lhs_src == rhs_src {
let file_format = match language {
Expand Down Expand Up @@ -500,7 +500,7 @@ fn diff_file_content(
let rhs_positions = line_parser::change_positions(rhs_src, lhs_src);
(file_format, lhs_positions, rhs_positions)
}
Some(lang_config) => {
Some((language, lang_config)) => {
let arena = Arena::new();
match tsp::to_tree_with_limit(diff_options, &lang_config, lhs_src, rhs_src) {
Ok((lhs_tree, rhs_tree)) => {
Expand All @@ -515,16 +515,11 @@ fn diff_file_content(
) {
Ok((lhs, rhs)) => {
if diff_options.check_only {
let file_format = match language {
Some(language) => FileFormat::SupportedLanguage(language),
None => FileFormat::PlainText,
};

let has_syntactic_changes = lhs != rhs;
return DiffResult {
extra_info,
display_path: display_path.to_string(),
file_format,
file_format: FileFormat::SupportedLanguage(language),
lhs_src: FileContent::Text(lhs_src.to_owned()),
rhs_src: FileContent::Text(rhs_src.to_owned()),
lhs_positions: vec![],
Expand Down Expand Up @@ -573,10 +568,6 @@ fn diff_file_content(
rhs_positions,
)
} else {
// TODO: Make this .expect() unnecessary.
let language = language.expect(
"If we had a ts_lang, we must have guessed the language",
);
fix_all_sliders(language, &lhs, &mut change_map);
fix_all_sliders(language, &rhs, &mut change_map);

Expand Down

0 comments on commit 40403b2

Please sign in to comment.