use codesort::*; static INPUT: &str = r#" /// The configuration read from conf.toml or conf.hjson file(s) #[derive(Default, Clone, Debug, Deserialize)] pub struct Conf { #[serde(alias="default-flags")] pub default_flags: Option, // the flags to apply before cli ones #[serde(alias="date-time-format")] pub date_time_format: Option, #[serde(default)] pub verbs: Vec, pub skin: Option>, #[serde(default, alias="special-paths")] pub special_paths: HashMap, #[serde(alias="search-modes")] pub search_modes: Option>, /// Obsolete, kept for compatibility: you should now use capture_mouse #[serde(alias="disable-mouse-capture")] pub disable_mouse_capture: Option, #[serde(alias="cols-order")] pub cols_order: Option, #[serde(alias="show-selection-mark")] pub show_selection_mark: Option, #[serde(alias="syntax-theme")] pub syntax_theme: Option, #[serde(alias="icon-theme")] pub icon_theme: Option, pub modal: Option, /// the initial mode (only relevant when modal is true) #[serde(alias="initial-mode")] pub initial_mode: Option, pub max_panels_count: Option, #[serde(alias="quit-on-last-cancel")] pub quit_on_last_cancel: Option, pub file_sum_threads_count: Option, #[serde(alias="max_staged_count")] pub max_staged_count: Option, #[serde(default)] pub imports: Vec, #[serde(alias="terminal-title")] pub terminal_title: Option, #[serde(alias="update-work-dir")] pub update_work_dir: Option, #[serde(alias="kitty-graphics-transmission")] pub kitty_graphics_transmission: Option, } "#; static OUTPUT: &str = r#" /// The configuration read from conf.toml or conf.hjson file(s) #[derive(Default, Clone, Debug, Deserialize)] pub struct Conf { #[serde(alias="cols-order")] pub cols_order: Option, #[serde(alias="date-time-format")] pub date_time_format: Option, #[serde(alias="default-flags")] pub default_flags: Option, // the flags to apply before cli ones /// Obsolete, kept for compatibility: you should now use capture_mouse #[serde(alias="disable-mouse-capture")] pub disable_mouse_capture: Option, pub file_sum_threads_count: Option, #[serde(alias="icon-theme")] pub icon_theme: Option, #[serde(default)] pub imports: Vec, /// the initial mode (only relevant when modal is true) #[serde(alias="initial-mode")] pub initial_mode: Option, #[serde(alias="kitty-graphics-transmission")] pub kitty_graphics_transmission: Option, pub max_panels_count: Option, #[serde(alias="max_staged_count")] pub max_staged_count: Option, pub modal: Option, #[serde(alias="quit-on-last-cancel")] pub quit_on_last_cancel: Option, #[serde(alias="search-modes")] pub search_modes: Option>, #[serde(alias="show-selection-mark")] pub show_selection_mark: Option, pub skin: Option>, #[serde(default, alias="special-paths")] pub special_paths: HashMap, #[serde(alias="syntax-theme")] pub syntax_theme: Option, #[serde(alias="terminal-title")] pub terminal_title: Option, #[serde(alias="update-work-dir")] pub update_work_dir: Option, #[serde(default)] pub verbs: Vec, } "#; #[test] fn test_struct_fields() { let list = LocList::read_str(INPUT, Language::Rust).unwrap(); let focused = list.focus_around_line_index(5).unwrap(); focused.print_debug(); { let blocks = focused.clone().focus.into_blocks(); for (i, block) in blocks.iter().enumerate() { block.print_debug(&format!(" BLOCK {i}")); } } let sorted_list = focused.sort(); sorted_list.print_debug(" SORTED "); assert_eq!(sorted_list.to_string(), OUTPUT); }