@@ -11,6 +11,7 @@ use super::mouse::{attach_selection_handlers, bounds_capture};
1111use crate :: app:: fonts;
1212use crate :: app:: theme:: Theme ;
1313use crate :: diff:: SbsSide ;
14+ use crate :: diff:: line:: ROW_HEIGHT ;
1415use crate :: diff:: side_by_side:: {
1516 SBS_GUTTER_WIDTH , sbs_new_content, sbs_new_gutter, sbs_old_content, sbs_old_gutter,
1617} ;
@@ -19,6 +20,7 @@ use crate::diff::wrap::{
1920} ;
2021use crate :: repo:: window:: { PanelBoundsSlot , RepoWindow } ;
2122use crate :: ui:: primitives:: no_scrollbar_gutter;
23+ use crate :: ui:: scrollbar:: vertical_uniform_scrollbar;
2224
2325pub ( super ) fn side_by_side_body (
2426 fd : & FileDiff ,
@@ -88,7 +90,7 @@ pub(super) fn side_by_side_body(
8890 rows,
8991 theme : theme. clone ( ) ,
9092 query,
91- scroll,
93+ scroll : scroll . clone ( ) ,
9294 side : SbsSide :: New ,
9395 bounds : new_bounds. clone ( ) ,
9496 advance,
@@ -108,13 +110,14 @@ pub(super) fn side_by_side_body(
108110 let content_panel = |list : UniformList ,
109111 bounds : PanelBoundsSlot ,
110112 side : SbsSide ,
113+ show_scrollbar : bool ,
111114 cx : & mut Context < RepoWindow > | {
112- div ( )
115+ let mut panel = div ( )
113116 . relative ( )
114117 . flex_1 ( )
115118 . min_w_0 ( )
116119 . h_full ( )
117- . child ( bounds_capture ( bounds) )
120+ . child ( bounds_capture ( bounds. clone ( ) ) )
118121 . on_mouse_up (
119122 MouseButton :: Left ,
120123 cx. listener ( move |v, _: & MouseUpEvent , _, cx| {
@@ -126,7 +129,17 @@ pub(super) fn side_by_side_body(
126129 }
127130 } ) ,
128131 )
129- . child ( no_scrollbar_gutter ( list) . h_full ( ) )
132+ . child ( no_scrollbar_gutter ( list) . h_full ( ) ) ;
133+ if show_scrollbar {
134+ panel = panel. child ( vertical_uniform_scrollbar (
135+ scroll. clone ( ) ,
136+ bounds,
137+ px ( count as f32 * ROW_HEIGHT ) ,
138+ theme. as_ref ( ) ,
139+ cx,
140+ ) ) ;
141+ }
142+ panel
130143 } ;
131144
132145 div ( )
@@ -135,10 +148,22 @@ pub(super) fn side_by_side_body(
135148 . h_full ( )
136149 . min_h_0 ( )
137150 . child ( gutter_panel ( old_gutter) )
138- . child ( content_panel ( old_content, old_bounds, SbsSide :: Old , cx) )
151+ . child ( content_panel (
152+ old_content,
153+ old_bounds,
154+ SbsSide :: Old ,
155+ false ,
156+ cx,
157+ ) )
139158 . child ( div ( ) . flex_none ( ) . w ( px ( 1. ) ) . h_full ( ) . bg ( rgb ( theme. border ) ) )
140159 . child ( gutter_panel ( new_gutter) )
141- . child ( content_panel ( new_content, new_bounds, SbsSide :: New , cx) )
160+ . child ( content_panel (
161+ new_content,
162+ new_bounds,
163+ SbsSide :: New ,
164+ true ,
165+ cx,
166+ ) )
142167 . into_any_element ( )
143168}
144169
0 commit comments