summaryrefslogtreecommitdiffstats
path: root/src/list/mod.rs
diff options
context:
space:
mode:
authorTim Oram <dev@mitmaro.ca>2020-09-17 10:45:49 -0230
committerTim Oram <dev@mitmaro.ca>2020-09-17 22:01:14 -0230
commitc6dbcc6017a7a1b343a585729239ad52ccb6ceba (patch)
tree5f27828bc435ef9eed85ebd835d55418985c07cb /src/list/mod.rs
parent10d797ebf3910f45f6ed3cd01573e531f388f31d (diff)
Move error handling to process module
The error handling module needed to have state provided to it from other modules, which meant that the other modules needed to understand how the error module worked. This was awkward and fragile. This moves the error handling code into the process module and makes it a global system. This has the advantage of not requiring tracking of the previous state and allows for the removal of the HandleInputResult struct.
Diffstat (limited to 'src/list/mod.rs')
-rw-r--r--src/list/mod.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/list/mod.rs b/src/list/mod.rs
index 9d27d7a..372950c 100644
--- a/src/list/mod.rs
+++ b/src/list/mod.rs
@@ -18,7 +18,6 @@ use crate::list::utils::{
get_visual_footer_full,
};
use crate::process::exit_status::ExitStatus;
-use crate::process::handle_input_result::{HandleInputResult, HandleInputResultBuilder};
use crate::process::process_module::ProcessModule;
use crate::process::process_result::ProcessResult;
use crate::process::state::State;
@@ -108,11 +107,11 @@ impl<'l> ProcessModule for List<'l> {
input_handler: &InputHandler<'_>,
git_interactive: &mut GitInteractive,
view: &View<'_>,
- ) -> HandleInputResult
+ ) -> ProcessResult
{
let (_, view_height) = view.get_view_size();
let input = input_handler.get_input(InputMode::List);
- let mut result = HandleInputResultBuilder::new(input);
+ let mut result = ProcessResult::new().input(input);
match input {
Input::MoveCursorLeft => self.view_data.scroll_left(),
Input::MoveCursorRight => self.view_data.scroll_right(),
@@ -131,7 +130,7 @@ impl<'l> ProcessModule for List<'l> {
}
let selected_index = *git_interactive.get_selected_line_index() - 1;
self.view_data.ensure_line_visible(selected_index);
- result.build()
+ result
}
fn get_help_keybindings_descriptions(&self) -> Option<&[(&str, &str)]> {
@@ -173,9 +172,9 @@ impl<'l> List<'l> {
fn handle_normal_mode_input(
&mut self,
input: Input,
- result: HandleInputResultBuilder,
+ result: ProcessResult,
git_interactive: &mut GitInteractive,
- ) -> HandleInputResultBuilder
+ ) -> ProcessResult
{
let mut result = result;
match input {
@@ -226,9 +225,9 @@ impl<'l> List<'l> {
fn handle_visual_mode_input(
&mut self,
input: Input,
- result: HandleInputResultBuilder,
+ result: ProcessResult,
git_interactive: &mut GitInteractive,
- ) -> HandleInputResultBuilder
+ ) -> ProcessResult
{
let mut result = result;
match input {