mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
use new VerticalScroll in diff aswell
This commit is contained in:
parent
3a849bc900
commit
535486f276
1 changed files with 14 additions and 19 deletions
|
|
@ -1,12 +1,13 @@
|
|||
use super::{
|
||||
CommandBlocking, Direction, DrawableComponent, ScrollType,
|
||||
utils::scroll_vertical::VerticalScroll, CommandBlocking,
|
||||
Direction, DrawableComponent, ScrollType,
|
||||
};
|
||||
use crate::{
|
||||
components::{CommandInfo, Component, EventState},
|
||||
keys::SharedKeyConfig,
|
||||
queue::{Action, InternalEvent, NeedsUpdate, Queue, ResetItem},
|
||||
strings, try_or_popup,
|
||||
ui::{self, calc_scroll_top, style::SharedTheme},
|
||||
ui::style::SharedTheme,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use asyncgit::{
|
||||
|
|
@ -105,7 +106,7 @@ pub struct DiffComponent {
|
|||
current_size: Cell<(u16, u16)>,
|
||||
focused: bool,
|
||||
current: Current,
|
||||
scroll_top: Cell<usize>,
|
||||
scroll: VerticalScroll,
|
||||
queue: Queue,
|
||||
theme: SharedTheme,
|
||||
key_config: SharedKeyConfig,
|
||||
|
|
@ -129,7 +130,7 @@ impl DiffComponent {
|
|||
diff: None,
|
||||
current_size: Cell::new((0, 0)),
|
||||
selection: Selection::Single(0),
|
||||
scroll_top: Cell::new(0),
|
||||
scroll: VerticalScroll::new(),
|
||||
theme,
|
||||
key_config,
|
||||
is_immutable,
|
||||
|
|
@ -150,7 +151,7 @@ impl DiffComponent {
|
|||
pub fn clear(&mut self, pending: bool) {
|
||||
self.current = Current::default();
|
||||
self.diff = None;
|
||||
self.scroll_top.set(0);
|
||||
self.scroll.reset();
|
||||
self.selection = Selection::Single(0);
|
||||
self.selected_hunk = None;
|
||||
self.pending = pending;
|
||||
|
|
@ -178,7 +179,7 @@ impl DiffComponent {
|
|||
self.diff = Some(diff);
|
||||
|
||||
if reset_selection {
|
||||
self.scroll_top.set(0);
|
||||
self.scroll.reset();
|
||||
self.selection = Selection::Single(0);
|
||||
self.update_selection(0);
|
||||
} else {
|
||||
|
|
@ -336,7 +337,7 @@ impl DiffComponent {
|
|||
Span::raw(Cow::from(")")),
|
||||
])]);
|
||||
} else {
|
||||
let min = self.scroll_top.get();
|
||||
let min = self.scroll.get();
|
||||
let max = min + height as usize;
|
||||
|
||||
let mut line_cursor = 0_usize;
|
||||
|
|
@ -604,11 +605,11 @@ impl DrawableComponent for DiffComponent {
|
|||
|
||||
let current_height = self.current_size.get().1;
|
||||
|
||||
self.scroll_top.set(calc_scroll_top(
|
||||
self.scroll_top.get(),
|
||||
current_height as usize,
|
||||
self.scroll.update(
|
||||
self.selection.get_end(),
|
||||
));
|
||||
self.lines_count(),
|
||||
usize::from(current_height),
|
||||
);
|
||||
|
||||
let title = format!(
|
||||
"{}{}",
|
||||
|
|
@ -637,15 +638,9 @@ impl DrawableComponent for DiffComponent {
|
|||
),
|
||||
r,
|
||||
);
|
||||
|
||||
if self.focused {
|
||||
ui::draw_scrollbar(
|
||||
f,
|
||||
r,
|
||||
&self.theme,
|
||||
self.lines_count()
|
||||
.saturating_sub(usize::from(current_height)),
|
||||
self.scroll_top.get(),
|
||||
);
|
||||
self.scroll.draw(f, r, &self.theme);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Reference in a new issue