diff options
author | Tim Oram <dev@mitmaro.ca> | 2022-11-18 09:43:27 -0330 |
---|---|---|
committer | Tim Oram <dev@mitmaro.ca> | 2022-11-18 10:09:07 -0330 |
commit | 75cdfffdd59715661e564470c133831a4e19253f (patch) | |
tree | dfdc3d48937f849d4a510dd3e70ae4adb4111ea9 | |
parent | 75a9257c1f88f3cc98c3339994ad5a3f3ce7f0d8 (diff) |
Add support for update-ref action
-rw-r--r-- | readme/customization.md | 45 | ||||
-rw-r--r-- | src/config/src/theme.rs | 8 | ||||
-rw-r--r-- | src/core/src/modules/insert/line_type.rs | 3 | ||||
-rw-r--r-- | src/core/src/modules/insert/mod.rs | 2 | ||||
-rw-r--r-- | src/core/src/modules/insert/tests.rs | 45 | ||||
-rw-r--r-- | src/core/src/modules/list/tests/render.rs | 8 | ||||
-rw-r--r-- | src/core/src/modules/list/utils.rs | 10 | ||||
-rw-r--r-- | src/display/src/display_color.rs | 2 | ||||
-rw-r--r-- | src/display/src/lib.rs | 22 | ||||
-rw-r--r-- | src/todo_file/src/action.rs | 12 | ||||
-rw-r--r-- | src/todo_file/src/line.rs | 43 | ||||
-rw-r--r-- | src/todo_file/src/search.rs | 11 | ||||
-rw-r--r-- | src/view/src/testutil.rs | 1 |
13 files changed, 182 insertions, 30 deletions
diff --git a/readme/customization.md b/readme/customization.md index 76dc3fc..06d667e 100644 --- a/readme/customization.md +++ b/readme/customization.md @@ -71,28 +71,29 @@ The valid colors are the [eight original 8 ANSI colors][ANSIColors]. They are `b [ANSIColors]:https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit -| Key | Default | Type | Description | -|---------------------------|-------------|-------|----------------------------------------------------------| -| `backgroundColor` | Default¹ | Color | Color used for the background | -| `breakColor` | white | Color | Color used for the break action | -| `diffAddColor` | green | Color | Color used for lines and files added in a diff | -| `diffChangeColor` | yellow | Color | Color used for lines and files changed in a diff | -| `diffContextColor` | white | Color | Color used for context in a diff | -| `diffRemoveColor` | red | Color | Color used for lines and files removed in a diff | -| `diffWhitespace` | black | Color | Color used for whitespace in a diff | -| `dropColor` | red | Color | Color used for the drop action | -| `editColor` | blue | Color | Color used for the edit action | -| `execColor` | blue | Color | Color used for the exec action | -| `fixupColor` | magenta | Color | Color used for the fixup action | -| `foregroundColor` | Default¹ | Color | Color used for most text and the UI | -| `indicatorColor` | cyan | Color | Color used for text the indicates or needs to standout | -| `labelColor` | dark yellow | Color | Color used for the label action | -| `mergeColor` | dark yellow | Color | Color used for the merge action | -| `pickColor` | green | Color | Color used for the pick action | -| `resetColor` | dark yellow | Color | Color used for the reset action | -| `rewordColor` | yellow | Color | Color used for the reword action | -| `selectedBackgroundColor` | 35,35,40 | Color | Color used as the background color for the selected line | -| `squashColor` | cyan | Color | Color used for the squash action | +| Key | Default | Type | Description | +|---------------------------|--------------|-------|----------------------------------------------------------| +| `backgroundColor` | Default¹ | Color | Color used for the background | +| `breakColor` | white | Color | Color used for the break action | +| `diffAddColor` | green | Color | Color used for lines and files added in a diff | +| `diffChangeColor` | yellow | Color | Color used for lines and files changed in a diff | +| `diffContextColor` | white | Color | Color used for context in a diff | +| `diffRemoveColor` | red | Color | Color used for lines and files removed in a diff | +| `diffWhitespace` | black | Color | Color used for whitespace in a diff | +| `dropColor` | red | Color | Color used for the drop action | +| `editColor` | blue | Color | Color used for the edit action | +| `execColor` | blue | Color | Color used for the exec action | +| `fixupColor` | magenta | Color | Color used for the fixup action | +| `foregroundColor` | Default¹ | Color | Color used for most text and the UI | +| `indicatorColor` | cyan | Color | Color used for text the indicates or needs to standout | +| `labelColor` | dark yellow | Color | Color used for the label action | +| `mergeColor` | dark yellow | Color | Color used for the merge action | +| `pickColor` | green | Color | Color used for the pick action | +| `resetColor` | dark yellow | Color | Color used for the reset action | +| `rewordColor` | yellow | Color | Color used for the reword action | +| `selectedBackgroundColor` | 35,35,40 | Color | Color used as the background color for the selected line | +| `squashColor` | cyan | Color | Color used for the squash action | +| `updateRefColor` | dark magenta | Color | Color used for the update-ref action | ¹ By default the foreground and background colors use the terminal defined colors diff --git a/src/config/src/theme.rs b/src/config/src/theme.rs index 7a6886e..4f49b06 100644 --- a/src/config/src/theme.rs +++ b/src/config/src/theme.rs @@ -50,6 +50,8 @@ pub struct Theme { pub color_action_reset: Color, /// The color for the merge action. pub color_action_merge: Color, + /// The color for the update-ref action. + pub color_action_update_ref: Color, /// The color for the background. pub color_background: Color, /// The color for added lines in a diff. @@ -98,6 +100,11 @@ impl Theme { color_action_label: get_color(git_config, "interactive-rebase-tool.labelColor", Color::DarkYellow)?, color_action_reset: get_color(git_config, "interactive-rebase-tool.resetColor", Color::DarkYellow)?, color_action_merge: get_color(git_config, "interactive-rebase-tool.mergeColor", Color::DarkYellow)?, + color_action_update_ref: get_color( + git_config, + "interactive-rebase-tool.updateRefColor", + Color::DarkMagenta, + )?, color_background: get_color(git_config, "interactive-rebase-tool.backgroundColor", Color::Default)?, color_diff_add: get_color(git_config, "interactive-rebase-tool.diffAddColor", Color::LightGreen)?, color_diff_change: get_color( @@ -218,6 +225,7 @@ mod tests { config_test!(color_action_label, "labelColor", Color::DarkYellow); config_test!(color_action_reset, "resetColor", Color::DarkYellow); config_test!(color_action_merge, "mergeColor", Color::DarkYellow); + config_test!(color_action_update_ref, "updateRefColor", Color::DarkMagenta); config_test!(color_background, "backgroundColor", Color::Default); config_test!(color_diff_add, "diffAddColor", Color::LightGreen); config_test!(color_diff_change, "diffChangeColor", Color::LightYellow); diff --git a/src/core/src/modules/insert/line_type.rs b/src/core/src/modules/insert/line_type.rs index 7c4c016..3b8b86d 100644 --- a/src/core/src/modules/insert/line_type.rs +++ b/src/core/src/modules/insert/line_type.rs @@ -6,6 +6,7 @@ pub(crate) enum LineType { Label, Merge, Reset, + UpdateRef, } impl ToString for LineType { @@ -17,6 +18,7 @@ impl ToString for LineType { Self::Label => String::from("label"), Self::Merge => String::from("merge"), Self::Reset => String::from("reset"), + Self::UpdateRef => String::from("update-ref"), } } } @@ -34,6 +36,7 @@ mod tests { #[case::label(&LineType::Label, "label")] #[case::merge(&LineType::Merge, "merge")] #[case::reset(&LineType::Reset, "reset")] + #[case::update_ref(&LineType::UpdateRef, "update-ref")] fn to_string(#[case] line_type: &LineType, #[case] expected: &str) { assert_eq!(line_type.to_string(), String::from(expected)); } diff --git a/src/core/src/modules/insert/mod.rs b/src/core/src/modules/insert/mod.rs index d912562..13519db 100644 --- a/src/core/src/modules/insert/mod.rs +++ b/src/core/src/modules/insert/mod.rs @@ -88,6 +88,7 @@ impl Module for Insert { LineType::Label => Line::new_label(content), LineType::Reset => Line::new_reset(content), LineType::Merge => Line::new_merge(content), + LineType::UpdateRef => Line::new_update_ref(content), // this should exit in the prompt state and never get here LineType::Cancel => unreachable!(), }; @@ -114,6 +115,7 @@ impl Insert { 'm', String::from("merge [-C <commit> | -c <commit>] <label> [# <oneline>]"), ), + (LineType::UpdateRef, 'u', String::from("update-ref <reference>")), (LineType::Cancel, 'q', String::from("Cancel add line")), ]); action_choices.set_prompt(vec![ViewLine::from("Select the type of line to insert:")]); diff --git a/src/core/src/modules/insert/tests.rs b/src/core/src/modules/insert/tests.rs index e379836..ea0c13a 100644 --- a/src/core/src/modules/insert/tests.rs +++ b/src/core/src/modules/insert/tests.rs @@ -29,6 +29,7 @@ fn render_prompt() { "{Normal}l) label <label>", "{Normal}r) reset <label>", "{Normal}m) merge [-C <commit> | -c <commit>] <label> [# <oneline>]", + "{Normal}u) update-ref <reference>", "{Normal}q) Cancel add line", "", "{IndicatorColor}Please choose an option." @@ -269,6 +270,50 @@ fn edit_render_merge() { } #[test] +fn update_ref_render_merge() { + module_test( + &[], + &[ + Event::from('u'), + Event::from('f'), + Event::from('o'), + Event::from('o'), + Event::from(KeyCode::Enter), + ], + |mut test_context| { + let mut module = Insert::new(); + let _ = test_context.handle_n_events(&mut module, 4); + let view_data = test_context.build_view_data(&mut module); + assert_rendered_output!( + view_data, + "{TITLE}", + "{LEADING}", + "{IndicatorColor}Enter contents of the new line. Empty content cancels creation of a new line.", + "", + "{BODY}", + "{Normal,Dimmed}update-ref {Normal}foo{Normal,Underline}", + "{TRAILING}", + "{IndicatorColor}Enter to finish" + ); + assert_results!( + test_context.handle_event(&mut module), + Artifact::Event(Event::from(KeyCode::Enter)), + Artifact::ChangeState(State::List) + ); + assert_eq!( + test_context + .todo_file_context + .todo_file() + .get_line(0) + .unwrap() + .to_text(), + "update-ref foo" + ); + }, + ); +} + +#[test] fn edit_select_next_index() { module_test( &["pick aaa c1"], diff --git a/src/core/src/modules/list/tests/render.rs b/src/core/src/modules/list/tests/render.rs index b5edaa6..067f75a 100644 --- a/src/core/src/modules/list/tests/render.rs +++ b/src/core/src/modules/list/tests/render.rs @@ -33,6 +33,7 @@ fn full() { "label ref", "reset ref", "merge command", + "update-ref reference", ], &[], |test_context| { @@ -53,7 +54,8 @@ fn full() { "{Normal} {ActionEdit}edit {Normal}11111111 comment 7", "{Normal} {ActionLabel}label {Normal}ref", "{Normal} {ActionReset}reset {Normal}ref", - "{Normal} {ActionMerge}merge {Normal}command" + "{Normal} {ActionMerge}merge {Normal}command", + "{Normal} {ActionUpdateRef}update-ref {Normal}reference" ); }, ); @@ -75,6 +77,7 @@ fn compact() { "label ref", "reset ref", "merge command", + "update-ref reference", ], &[], |mut test_context| { @@ -96,7 +99,8 @@ fn compact() { "{Normal} {ActionEdit}e {Normal}111 comment 7", "{Normal} {ActionLabel}l {Normal}ref", "{Normal} {ActionReset}t {Normal}ref", - "{Normal} {ActionMerge}m {Normal}command" + "{Normal} {ActionMerge}m {Normal}command", + "{Normal} {ActionUpdateRef}u {Normal}reference" ); }, ); diff --git a/src/core/src/modules/list/utils.rs b/src/core/src/modules/list/utils.rs index 08edd39..bcc20fa 100644 --- a/src/core/src/modules/list/utils.rs +++ b/src/core/src/modules/list/utils.rs @@ -190,6 +190,7 @@ const fn get_action_color(action: Action) -> DisplayColor { Action::Label => DisplayColor::ActionLabel, Action::Reset => DisplayColor::ActionReset, Action::Merge => DisplayColor::ActionMerge, + Action::UpdateRef => DisplayColor::ActionUpdateRef, // this is technically impossible, since noops should never be rendered Action::Noop => DisplayColor::Normal, } @@ -251,6 +252,7 @@ pub(super) fn get_todo_line_segments( get_action_color(*action), )); + // render hash match *action { Action::Drop | Action::Edit | Action::Fixup | Action::Pick | Action::Reword | Action::Squash => { let action_width = if is_full_width { 8 } else { 3 }; @@ -276,7 +278,13 @@ pub(super) fn get_todo_line_segments( )); segments.push(LineSegment::new(" ")); }, - Action::Exec | Action::Label | Action::Reset | Action::Merge | Action::Break | Action::Noop => {}, + Action::Exec + | Action::Label + | Action::Reset + | Action::Merge + | Action::Break + | Action::Noop + | Action::UpdateRef => {}, } let content = line.get_content(); if !content.is_empty() { diff --git a/src/display/src/display_color.rs b/src/display/src/display_color.rs index 1c7ba87..1207f6b 100644 --- a/src/display/src/display_color.rs +++ b/src/display/src/display_color.rs @@ -24,6 +24,8 @@ pub enum DisplayColor { ActionReset, /// The color for the merge action. ActionMerge, + /// The color for the merge action. + ActionUpdateRef, /// The color for added lines in a diff. DiffAddColor, /// The color for changed lines in a diff. diff --git a/src/display/src/lib.rs b/src/display/src/lib.rs index f6407c3..9b8b2a6 100644 --- a/src/display/src/lib.rs +++ b/src/display/src/lib.rs @@ -172,6 +172,7 @@ pub struct Display<T: Tui> { action_reset: (Colors, Colors), action_reword: (Colors, Colors), action_squash: (Colors, Colors), + action_update_ref: (Colors, Colors), tui: T, diff_add: (Colors, Colors), diff_change: (Colors, Colors), @@ -265,6 +266,12 @@ impl<T: Tui> Display<T> { theme.color_background, theme.color_selected_background, ); + let action_update_ref = register_selectable_color_pairs( + color_mode, + theme.color_action_update_ref, + theme.color_background, + theme.color_selected_background, + ); let diff_add = register_selectable_color_pairs( color_mode, theme.color_diff_add, @@ -308,6 +315,7 @@ impl<T: Tui> Display<T> { action_reset, action_reword, action_squash, + action_update_ref, tui, diff_add, diff_change, @@ -371,6 +379,7 @@ impl<T: Tui> Display<T> { DisplayColor::ActionLabel => self.action_label.1, DisplayColor::ActionReset => self.action_reset.1, DisplayColor::ActionMerge => self.action_merge.1, + DisplayColor::ActionUpdateRef => self.action_update_ref.1, DisplayColor::Normal => self.normal.1, DisplayColor::IndicatorColor => self.indicator.1, DisplayColor::DiffAddColor => self.diff_add.1, @@ -393,6 +402,7 @@ impl<T: Tui> Display<T> { DisplayColor::ActionLabel => self.action_label.0, DisplayColor::ActionReset => self.action_reset.0, DisplayColor::ActionMerge => self.action_merge.0, + DisplayColor::ActionUpdateRef => self.action_update_ref.0, DisplayColor::Normal => self.normal.0, DisplayColor::IndicatorColor => self.indicator.0, DisplayColor::DiffAddColor => self.diff_add.0, @@ -595,6 +605,18 @@ mod tests { CrosstermColor::DarkYellow, CrosstermColor::AnsiValue(237) )] + #[case::action_update_ref( + DisplayColor::ActionUpdateRef, + false, + CrosstermColor::DarkMagenta, + CrosstermColor::Reset + )] + #[case::action_update_ref_selected( + DisplayColor::ActionUpdateRef, + true, + CrosstermColor::DarkMagenta, + CrosstermColor::AnsiValue(237) + )] #[case::normal(DisplayColor::Normal, false, CrosstermColor::Reset, CrosstermColor::Reset)] #[case::normal_selected(DisplayColor::Normal, true, CrosstermColor::Reset, CrosstermColor::AnsiValue(237))] #[case::indicator(DisplayColor::IndicatorColor, false, CrosstermColor::Cyan, CrosstermColor::Reset)] diff --git a/src/todo_file/src/action.rs b/src/todo_file/src/action.rs index 8283a44..b338758 100644 --- a/src/todo_file/src/action.rs +++ b/src/todo_file/src/action.rs @@ -30,6 +30,8 @@ pub enum Action { Reset, /// A merge action. Merge, + /// Update a reference + UpdateRef, } impl Action { @@ -50,6 +52,7 @@ impl Action { Self::Reset => "t", Self::Reword => "r", Self::Squash => "s", + Self::UpdateRef => "u", }) } @@ -58,7 +61,7 @@ impl Action { #[inline] pub const fn is_static(self) -> bool { match self { - Self::Break | Self::Exec | Self::Noop | Self::Reset | Self::Label | Self::Merge => true, + Self::Break | Self::Exec | Self::Noop | Self::Reset | Self::Label | Self::Merge | Self::UpdateRef => true, Self::Drop | Self::Edit | Self::Fixup | Self::Pick | Self::Reword | Self::Squash => false, } } @@ -80,6 +83,7 @@ impl Display for Action { Self::Reset => "reset", Self::Reword => "reword", Self::Squash => "squash", + Self::UpdateRef => "update-ref", }) } } @@ -102,6 +106,7 @@ impl TryFrom<&str> for Action { "label" | "l" => Ok(Self::Label), "reset" | "t" => Ok(Self::Reset), "merge" | "m" => Ok(Self::Merge), + "update-ref" | "u" => Ok(Self::UpdateRef), _ => Err(ParseError::InvalidAction(String::from(s))), } } @@ -128,6 +133,7 @@ mod tests { #[case::label(Action::Label, "label")] #[case::reset(Action::Reset, "reset")] #[case::merge(Action::Merge, "merge")] + #[case::update_ref(Action::UpdateRef, "update-ref")] fn to_string(#[case] action: Action, #[case] expected: &str) { assert_eq!(format!("{action}"), expected); } @@ -157,6 +163,8 @@ mod tests { #[case::reset("reset", Action::Reset)] #[case::m("m", Action::Merge)] #[case::merge("merge", Action::Merge)] + #[case::u("u", Action::UpdateRef)] + #[case::update_ref("update-ref", Action::UpdateRef)] fn try_from(#[case] action_str: &str, #[case] expected: Action) { assert_ok_eq!(Action::try_from(action_str), expected); } @@ -180,6 +188,7 @@ mod tests { #[case::l(Action::Label, "l")] #[case::t(Action::Reset, "t")] #[case::m(Action::Merge, "m")] + #[case::u(Action::UpdateRef, "u")] fn to_abbreviation(#[case] action: Action, #[case] expected: &str) { assert_eq!(action.to_abbreviation(), expected); } @@ -197,6 +206,7 @@ mod tests { #[case::label(Action::Label, true)] #[case::reset(Action::Reset, true)] #[case::merge(Action::Merge, true)] + #[case::update_ref(Action::UpdateRef, true)] fn module_lifecycle(#[case] action: Action, #[case] expected: bool) { assert_eq!(action.is_static(), expected); } diff --git a/src/todo_file/src/line.rs b/src/todo_file/src/line.rs index 3109754..6f1abbc 100644 --- a/src/todo_file/src/line.rs +++ b/src/todo_file/src/line.rs @@ -93,6 +93,18 @@ impl Line { } } + /// Create a new update-ref line. + #[must_use] + #[inline] + pub fn new_update_ref(ref_name: &str) -> Self { + Self { + action: Action::UpdateRef, + content: String::from(ref_name), + hash: String::new(), + mutated: false, + } + } + /// Create a new line from a rebase file line. /// /// # Errors @@ -114,6 +126,8 @@ impl Line { || input_line.starts_with('l') || input_line.starts_with("reset") || input_line.starts_with('t') + || input_line.starts_with("update-ref") + || input_line.starts_with('u') { let input: Vec<&str> = input_line.splitn(2, ' ').collect(); if input.len() == 2 { @@ -195,7 +209,7 @@ impl Line { #[inline] pub const fn is_editable(&self) -> bool { match self.action { - Action::Exec | Action::Label | Action::Reset | Action::Merge => true, + Action::Exec | Action::Label | Action::Reset | Action::Merge | Action::UpdateRef => true, Action::Break | Action::Drop | Action::Edit @@ -215,7 +229,7 @@ impl Line { Action::Drop | Action::Edit | Action::Fixup | Action::Pick | Action::Reword | Action::Squash => { format!("{} {} {}", self.action, self.hash, self.content) }, - Action::Exec | Action::Label | Action::Reset | Action::Merge => { + Action::Exec | Action::Label | Action::Reset | Action::Merge | Action::UpdateRef => { format!("{} {}", self.action, self.content) }, Action::Noop | Action::Break => self.action.to_string(), @@ -298,6 +312,12 @@ mod tests { content: String::from("command"), mutated: false, })] + #[case::update_ref_action("update-ref reference", &Line { + action: Action::UpdateRef, + hash: String::new(), + content: String::from("reference"), + mutated: false, + })] #[case::break_action("break", &Line { action: Action::Break, hash: String::new(), @@ -375,6 +395,16 @@ mod tests { } #[test] + fn line_new_update_ref() { + assert_eq!(Line::new_update_ref("reference"), Line { + action: Action::UpdateRef, + hash: String::new(), + content: String::from("reference"), + mutated: false, + }); + } + + #[test] fn new_err_invalid_action() { assert_err_eq!( Line::new("invalid aaa comment"), @@ -394,6 +424,7 @@ mod tests { #[case::label_line_only("label")] #[case::reset_line_only("reset")] #[case::merge_line_only("merge")] + #[case::update_ref_line_only("update-ref")] fn new_err(#[case] line: &str) { assert_err_eq!(Line::new(line), ParseError::InvalidLine(String::from(line))); } @@ -418,6 +449,7 @@ mod tests { #[case::reset_action(Action::Reset, Action::Fixup)] #[case::merge_action(Action::Merge, Action::Fixup)] #[case::exec(Action::Exec, Action::Fixup)] + #[case::update_ref(Action::UpdateRef, Action::Fixup)] #[case::noop(Action::Noop, Action::Fixup)] fn set_action_static(#[case] from: Action, #[case] to: Action) { let mut line = Line::new(format!("{from} comment").as_str()).unwrap(); @@ -454,6 +486,7 @@ mod tests { #[case::label("label ref", "new")] #[case::reset("reset ref", "new")] #[case::merge("merge command", "new")] + #[case::update_ref("update-ref reference", "new")] fn edit_content(#[case] line: &str, #[case] expected: &str) { let mut line = Line::new(line).unwrap(); line.edit_content("new"); @@ -472,6 +505,7 @@ mod tests { #[case::label("label reference", "reference")] #[case::reset("reset reference", "reference")] #[case::merge("merge command", "command")] + #[case::update_ref("update-ref reference", "reference")] fn get_content(#[case] line: &str, #[case] expected: &str) { assert_eq!(Line::new(line).unwrap().get_content(), expected); } @@ -488,6 +522,7 @@ mod tests { #[case::label("label reference", Action::Label)] #[case::reset("reset reference", Action::Reset)] #[case::merge("merge command", Action::Merge)] + #[case::update_ref("update-ref reference", Action::UpdateRef)] fn get_action(#[case] line: &str, #[case] expected: Action) { assert_eq!(Line::new(line).unwrap().get_action(), &expected); } @@ -504,6 +539,7 @@ mod tests { #[case::label("label reference", "")] #[case::reset("reset reference", "")] #[case::merge("merge command", "")] + #[case::update_ref("update-ref reference", "")] fn get_hash(#[case] line: &str, #[case] expected: &str) { assert_eq!(Line::new(line).unwrap().get_hash(), expected); } @@ -520,6 +556,7 @@ mod tests { #[case::label("label ref", false)] #[case::reset("reset ref", false)] #[case::merge("merge command", false)] + #[case::update_ref("update-ref reference", false)] fn has_reference(#[case] line: &str, #[case] expected: bool) { assert_eq!(Line::new(line).unwrap().has_reference(), expected); } @@ -537,6 +574,7 @@ mod tests { #[case::label(Action::Label, true)] #[case::reset(Action::Reset, true)] #[case::merge(Action::Merge, true)] + #[case::update_ref(Action::UpdateRef, true)] fn is_editable(#[case] from: Action, #[case] editable: bool) { let line = Line::new(format!("{from} aaa bbb").as_str()).unwrap(); assert_eq!(line.is_editable(), editable); @@ -554,6 +592,7 @@ mod tests { #[case::label("label reference")] #[case::reset("reset reference")] #[case::merge("merge command")] + #[case::update_ref("update-ref reference")] fn to_text(#[case] line: &str) { assert_eq!(Line::new(line).unwrap().to_text(), line); } diff --git a/src/todo_file/src/search.rs b/src/todo_file/src/search.rs index a4745ee..0192e8f 100644 --- a/src/todo_file/src/search.rs +++ b/src/todo_file/src/search.rs @@ -35,7 +35,13 @@ impl Search { for (i, line) in rebase_todo.lines_iter().enumerate() { match *line.get_action() { Action::Break | Action::Noop => continue, - Action::Drop | Action::Edit | Action::Fixup | Action::Pick | Action::Reword | Action::Squash => { + Action::Drop + | Action::Edit + | Action::Fixup + | Action::Pick + | Action::Reword + | Action::Squash + | Action::UpdateRef => { if line.get_hash().starts_with(term) || line.get_content().contains(term) { self.matches.push(i); } @@ -268,11 +274,12 @@ mod tests { "reset foobar", "merge foobar", "exec foobar", + "update-ref foobar", ], |context| { let mut search = Search::new(); assert!(search.search(context.todo_file(), "ooba")); - assert_eq!(search.total_results(), 4); + assert_eq!(search.total_results(), 5); }, ); } diff --git a/src/view/src/testutil.rs b/src/view/src/testutil.rs index bd10382..354a431 100644 --- a/src/view/src/testutil.rs +++ b/src/view/src/testutil.rs @@ -68,6 +68,7 @@ fn render_style(line_segment: &LineSegment) -> String { DisplayColor::ActionLabel => String::from("ActionLabel"), DisplayColor::ActionReset => String::from("ActionReset"), DisplayColor::ActionMerge => String::from("ActionMerge"), + DisplayColor::ActionUpdateRef => String::from("ActionUpdateRef"), }; let mut style = vec![]; |