Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,13 @@ fn detect_syntax_name(file_path: Option<&str>, lines: &[String]) -> Option<Strin
if let Some(file_name) = path.file_name().and_then(|name| name.to_str()) {
let file_name_lower = file_name.to_ascii_lowercase();

if is_dotenv_file_name(&file_name_lower) {
if let Some(syntax) = syntaxes
if is_dotenv_file_name(&file_name_lower)
&& let Some(syntax) = syntaxes
.find_syntax_by_name(DOTENV_SYNTAX_NAME)
.or_else(|| syntaxes.find_syntax_by_token("dotenv"))
.or_else(|| syntaxes.find_syntax_by_extension("env"))
{
return Some(syntax.name.clone());
}
{
return Some(syntax.name.clone());
}

if let Some(syntax) = syntaxes.find_syntax_by_token(file_name) {
Expand Down Expand Up @@ -433,10 +432,7 @@ fn detect_syntax_name(file_path: Option<&str>, lines: &[String]) -> Option<Strin
let first_line = lines
.iter()
.find(|line| !line.trim().is_empty())
.or_else(|| lines.first());
let Some(first_line) = first_line else {
return None;
};
.or_else(|| lines.first())?;

syntaxes
.find_syntax_by_first_line(first_line)
Expand Down
4 changes: 3 additions & 1 deletion src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn should_prefer_dark_theme() -> bool {

if let Ok(value) = std::env::var("COLORFGBG") {
let background_index = value
.split(|ch| ch == ';' || ch == ':')
.split([';', ':'])
.next_back()
.and_then(parse_terminal_palette_index);

Expand Down Expand Up @@ -215,6 +215,7 @@ fn highlight_visible_content(
.collect()
}

#[allow(clippy::too_many_arguments)]
fn format_pane_line(
line_value: Option<&str>,
line_index: usize,
Expand Down Expand Up @@ -331,6 +332,7 @@ pub(crate) fn get_pane_for_column(column: usize, layout: &FrameLayout) -> Option
None
}

#[allow(clippy::too_many_arguments)]
pub(crate) fn render_frame(
files: &[DiffFileView],
comparison: &ResolvedComparison,
Expand Down
15 changes: 7 additions & 8 deletions src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,14 @@ pub(crate) fn start_interactive_review(
Show,
DisableMouseCapture,
LeaveAlternateScreen
) {
if restore_error.is_none() {
restore_error = Some(error.into());
}
) && restore_error.is_none()
{
restore_error = Some(error.into());
}
if let Err(error) = terminal.show_cursor() {
if restore_error.is_none() {
restore_error = Some(error.into());
}
if let Err(error) = terminal.show_cursor()
&& restore_error.is_none()
{
restore_error = Some(error.into());
}

if let Some(error) = restore_error {
Expand Down