refactor: Take clippy nightly suggestions into account (#456)

Refactor in regards to clippy nightly. Mostly deals with suggestions with duplicate code on multiple branches.
This commit is contained in:
Clement Tsang 2021-04-23 00:06:07 -04:00 committed by GitHub
parent f33bb42c5b
commit 0148432b15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 14 deletions

View File

@ -57,8 +57,6 @@ impl HelpDialog for Painter {
});
app_state.help_dialog_state.index_shortcuts[itx] = 0;
prev_section_len = section.len() as u16 + buffer;
overflow_buffer += buffer;
} else {
section.iter().for_each(|text_line| {
buffer += UnicodeWidthStr::width(*text_line).saturating_sub(1) as u16
@ -69,9 +67,9 @@ impl HelpDialog for Painter {
app_state.help_dialog_state.index_shortcuts[itx - 1]
+ 1
+ prev_section_len;
prev_section_len = section.len() as u16 + buffer;
overflow_buffer += buffer;
}
prev_section_len = section.len() as u16 + buffer;
overflow_buffer += buffer;
});
app_state.help_dialog_state.scroll_state.max_scroll_index =

View File

@ -151,14 +151,11 @@ pub fn get_search_start_position(
if current_cursor_position <= *cursor_bar {
// If it's past the first element, then show from that element downwards
*cursor_bar = current_cursor_position;
*cursor_bar
} else if current_cursor_position >= *cursor_bar + num_columns {
*cursor_bar = current_cursor_position - num_columns;
*cursor_bar
} else {
// Else, don't change what our start position is from whatever it is set to!
*cursor_bar
}
// Else, don't change what our start position is from whatever it is set to!
*cursor_bar
}
}
}
@ -191,14 +188,11 @@ pub fn get_start_position(
if currently_selected_position <= *scroll_position_bar {
// If it's past the first element, then show from that element downwards
*scroll_position_bar = currently_selected_position;
*scroll_position_bar
} else if currently_selected_position >= *scroll_position_bar + num_rows {
*scroll_position_bar = currently_selected_position - num_rows;
*scroll_position_bar
} else {
// Else, don't change what our start position is from whatever it is set to!
*scroll_position_bar
}
// Else, don't change what our start position is from whatever it is set to!
*scroll_position_bar
}
}
}