• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MitMaro / git-interactive-rebase-tool / 24379379782

14 Apr 2026 03:27AM UTC coverage: 93.969% (-3.6%) from 97.589%
24379379782

Pull #988

github

web-flow
Merge 0e7f07116 into 4d16b296a
Pull Request #988: Bump rand from 0.9.0 to 0.9.4

5531 of 5886 relevant lines covered (93.97%)

6.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.89
/src/components/edit.rs
1
#[cfg(test)]
2
mod tests;
3

4
use std::sync::LazyLock;
5

6
use crate::{
7
        components::shared::EditableLine,
8
        display::DisplayColor,
9
        input::{Event, InputOptions, KeyCode, KeyEvent, KeyModifiers},
10
        view::{LineSegment, LineSegmentOptions, ViewData, ViewDataUpdater, ViewLine},
11
};
12

13
pub(crate) static INPUT_OPTIONS: LazyLock<InputOptions> = LazyLock::new(|| InputOptions::RESIZE);
2✔
14

15
const FINISH_EVENT: Event = Event::Key(KeyEvent {
16
        code: KeyCode::Enter,
17
        modifiers: KeyModifiers::NONE,
18
});
19

20
pub(crate) struct Edit {
21
        editable_line: EditableLine,
22
        finished: bool,
23
        view_data: ViewData,
24
}
25

26
impl Edit {
27
        pub(crate) fn new() -> Self {
1✔
28
                let view_data = ViewData::new(|updater| {
2✔
29
                        updater.set_show_title(true);
1✔
30
                });
31
                Self {
32
                        editable_line: EditableLine::new(),
1✔
33
                        finished: false,
34
                        view_data,
35
                }
36
        }
37

38
        pub(crate) fn build_view_data<F, G>(&mut self, before_build: F, after_build: G) -> &ViewData
5✔
39
        where
40
                F: FnOnce(&mut ViewDataUpdater<'_>),
41
                G: FnOnce(&mut ViewDataUpdater<'_>),
42
        {
43
                self.view_data.update_view_data(|updater| {
11✔
44
                        updater.clear();
6✔
45
                        before_build(updater);
6✔
46
                        updater.push_line(ViewLine::from(self.editable_line.line_segments()));
6✔
47
                        updater.push_trailing_line(ViewLine::new_pinned(vec![LineSegment::new_with_color(
6✔
48
                                "Enter to finish",
×
49
                                DisplayColor::IndicatorColor,
×
50
                        )]));
51
                        updater.ensure_column_visible(self.editable_line.cursor_position());
6✔
52
                        updater.ensure_line_visible(0);
6✔
53
                        after_build(updater);
6✔
54
                });
55
                &self.view_data
×
56
        }
57

58
        pub(crate) fn get_view_data(&mut self) -> &ViewData {
1✔
59
                self.build_view_data(|_| {}, |_| {})
5✔
60
        }
61

62
        pub(crate) fn handle_event(&mut self, event: Event) {
1✔
63
                if event == FINISH_EVENT {
1✔
64
                        self.finished = true;
1✔
65
                }
66
                else {
67
                        _ = self.editable_line.handle_event(event);
1✔
68
                }
69
        }
70

71
        pub(crate) fn set_label(&mut self, label: &str) {
3✔
72
                self.editable_line.set_label(LineSegment::new_with_color_and_style(
3✔
73
                        label,
74
                        DisplayColor::Normal,
75
                        LineSegmentOptions::DIMMED,
76
                ));
77
        }
78

79
        pub(crate) fn set_content(&mut self, content: &str) {
1✔
80
                self.editable_line.set_content(content);
1✔
81
        }
82

83
        pub(crate) fn reset(&mut self) {
1✔
84
                self.editable_line.clear();
1✔
85
                self.editable_line.set_read_only(false);
1✔
86
                self.finished = false;
1✔
87
        }
88

89
        pub(crate) fn input_options(&self) -> &InputOptions {
1✔
90
                &INPUT_OPTIONS
1✔
91
        }
92

93
        pub(crate) const fn is_finished(&self) -> bool {
1✔
94
                self.finished
1✔
95
        }
96

97
        pub(crate) fn get_content(&self) -> &str {
1✔
98
                self.editable_line.get_content()
1✔
99
        }
100
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc