|
1 |
| -use std::{collections::BTreeMap, mem::take}; |
| 1 | +use std::{collections::BTreeMap, mem::take, ops::Bound}; |
2 | 2 |
|
3 | 3 | use egui::{
|
4 | 4 | text::LayoutJob, CollapsingHeader, Color32, Id, OpenUrl, ScrollArea, SelectableLabel, TextEdit,
|
@@ -649,7 +649,55 @@ pub fn symbol_list_ui(
|
649 | 649 | }
|
650 | 650 | }
|
651 | 651 |
|
652 |
| - hotkeys::check_scroll_hotkeys(ui); |
| 652 | + hotkeys::check_scroll_hotkeys(ui, false); |
| 653 | + |
| 654 | + let mut new_key_value_to_highlight = None; |
| 655 | + if let Some(sym_ref) = |
| 656 | + if column == 0 { state.highlighted_symbol.0 } else { state.highlighted_symbol.1 } |
| 657 | + { |
| 658 | + let up = if hotkeys::consume_up_key(ui.ctx()) { |
| 659 | + Some(true) |
| 660 | + } else if hotkeys::consume_down_key(ui.ctx()) { |
| 661 | + Some(false) |
| 662 | + } else { |
| 663 | + None |
| 664 | + }; |
| 665 | + if let Some(mut up) = up { |
| 666 | + if state.reverse_fn_order { |
| 667 | + up = !up; |
| 668 | + } |
| 669 | + new_key_value_to_highlight = if up { |
| 670 | + mapping.range(..sym_ref).next_back() |
| 671 | + } else { |
| 672 | + mapping.range((Bound::Excluded(sym_ref), Bound::Unbounded)).next() |
| 673 | + }; |
| 674 | + }; |
| 675 | + } else { |
| 676 | + // No symbol is highlighted in this column. Select the topmost symbol instead. |
| 677 | + // Note that we intentionally do not consume the up/down key presses in this case, but |
| 678 | + // we do when a symbol is highlighted. This is so that if only one column has a symbol |
| 679 | + // highlighted, that one takes precedence over the one with nothing highlighted. |
| 680 | + if hotkeys::up_pressed(ui.ctx()) || hotkeys::down_pressed(ui.ctx()) { |
| 681 | + new_key_value_to_highlight = if state.reverse_fn_order { |
| 682 | + mapping.last_key_value() |
| 683 | + } else { |
| 684 | + mapping.first_key_value() |
| 685 | + }; |
| 686 | + } |
| 687 | + } |
| 688 | + if let Some((new_sym_ref, new_symbol_diff)) = new_key_value_to_highlight { |
| 689 | + ret = Some(if column == 0 { |
| 690 | + DiffViewAction::SetSymbolHighlight( |
| 691 | + Some(*new_sym_ref), |
| 692 | + new_symbol_diff.target_symbol, |
| 693 | + ) |
| 694 | + } else { |
| 695 | + DiffViewAction::SetSymbolHighlight( |
| 696 | + new_symbol_diff.target_symbol, |
| 697 | + Some(*new_sym_ref), |
| 698 | + ) |
| 699 | + }); |
| 700 | + } |
653 | 701 |
|
654 | 702 | ui.scope(|ui| {
|
655 | 703 | ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
|
0 commit comments