File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -399,6 +399,12 @@ impl Editor {
399
399
}
400
400
}
401
401
402
+ fn has_multiple_hunks ( & self , cx : & AppContext ) -> bool {
403
+ let snapshot = self . buffer . read ( cx) . snapshot ( cx) ;
404
+ let mut hunks = snapshot. git_diff_hunks_in_range ( MultiBufferRow :: MIN ..MultiBufferRow :: MAX ) ;
405
+ hunks. nth ( 1 ) . is_some ( )
406
+ }
407
+
402
408
fn hunk_header_block (
403
409
& self ,
404
410
hunk : & HoveredHunk ,
@@ -428,6 +434,7 @@ impl Editor {
428
434
render : Arc :: new ( {
429
435
let editor = cx. view ( ) . clone ( ) ;
430
436
let hunk = hunk. clone ( ) ;
437
+ let has_multiple_hunks = self . has_multiple_hunks ( cx) ;
431
438
432
439
move |cx| {
433
440
let hunk_controls_menu_handle =
@@ -471,6 +478,7 @@ impl Editor {
471
478
IconButton :: new ( "next-hunk" , IconName :: ArrowDown )
472
479
. shape ( IconButtonShape :: Square )
473
480
. icon_size ( IconSize :: Small )
481
+ . disabled ( !has_multiple_hunks)
474
482
. tooltip ( {
475
483
let focus_handle = editor. focus_handle ( cx) ;
476
484
move |cx| {
@@ -499,6 +507,7 @@ impl Editor {
499
507
IconButton :: new ( "prev-hunk" , IconName :: ArrowUp )
500
508
. shape ( IconButtonShape :: Square )
501
509
. icon_size ( IconSize :: Small )
510
+ . disabled ( !has_multiple_hunks)
502
511
. tooltip ( {
503
512
let focus_handle = editor. focus_handle ( cx) ;
504
513
move |cx| {
You can’t perform that action at this time.
0 commit comments