id
stringlengths
20
30
source
stringclasses
1 value
chunk_index
int64
0
520k
token_count
int32
154
512
content
stringlengths
185
57.5k
rust_dataset_chunk_511200
rust_dataset.txt
511,200
512
len == 0 { return; } let mut next = match self.tree_cursor() { Some(cursor) => (cursor as isize + delta).clamp(0, len as isize - 1) as usize, None if delta < 0 => len - 1, None => 0, }; if self.panel.tree.is_heading(next) && delta < 0 && n...
rust_dataset_chunk_511201
rust_dataset.txt
511,201
512
true; }, TreeNode::Recent | TreeNode::Session => return false, TreeNode::Tab(tab) => (tab, None), TreeNode::Pane(tab, pane) => (tab, Some(pane)), }; let is_running = matches!(self.selected_session(), Some((_, true, _))); if !is_running { ...
rust_dataset_chunk_511202
rust_dataset.txt
511,202
512
.max(self.panel.display.rows); let (width, height) = self.inbox.card_dimensions(screen_rows); set_popup_size(width, height); } } fn shows_browser_tabs(&self) -> bool { !self.is_welcome_screen && !self.attention_disabled() } fn attention_disabled(&...
rust_dataset_chunk_511203
rust_dataset.txt
511,203
512
(|s| s.name.clone()) .collect(), }; names.sort(); names.dedup(); names } fn render_app_quit(&self, rows: usize, cols: usize) { let lines = app_panel::quit_lines(&self.app_panel_sessions()); let (x, y, shown) = app_panel::centered_block(&lines, row...
rust_dataset_chunk_511204
rust_dataset.txt
511,204
512
view { _ if self.attention_disabled() => BrowserTab::Sessions, Some("sessions") => BrowserTab::Sessions, Some("inbox") => BrowserTab::Inbox, _ if !self.inbox.has_rows() => BrowserTab::Sessions, _ => BrowserTab::Inbox, }; self.switch_browser_ta...
rust_dataset_chunk_511205
rust_dataset.txt
511,205
512
osen = true; self.inbox.select_newest_counted(); }, } self.inbox_requested = false; self.go_to_size(PanelSize::Manager); } fn go_back_to_previous(&mut self) { run_action(actions::Action::ToggleSession, BTreeMap::new()); self.panel.size = None; ...
rust_dataset_chunk_511206
rust_dataset.txt
511,206
512
Ctrl]); match key.bare_key { BareKey::Esc if plain => { self.size_down(); Some(true) }, BareKey::Enter if plain => { match self.inbox.card_hovered.clone() { Some(target) => self.activate_card_target(target), ...
rust_dataset_chunk_511207
rust_dataset.txt
511,207
512
.inbox.move_selection(1), BareKey::Up if plain => self.inbox.move_selection(-1), BareKey::PageDown if plain => self.inbox.move_selection(10), BareKey::PageUp if plain => self.inbox.move_selection(-10), BareKey::Enter if is_alt_enter(&key) => { self.inbox.s...
rust_dataset_chunk_511208
rust_dataset.txt
511,208
512
) if !typing => { let hovered = match self.inbox.browser_target_at(line, column) { Some(BrowserTarget::Item(key)) => Some(key), _ => None, }; if hovered == self.inbox.hovered { return false; } ...
rust_dataset_chunk_511209
rust_dataset.txt
511,209
512
).cloned() { self.panel.tree.toggle(&row); } return true; } let typing = self.inbox.is_capturing(); match self.tree_row_at(line, column) { Some(index) if self.p...
rust_dataset_chunk_511210
rust_dataset.txt
511,210
512
{ assert_eq!( wrap_words("one two three four", 9), vec!["one two", "three", "four"] ); assert_eq!( wrap_words("averyveryverylongword x", 5), vec!["averyveryverylongword", "x"] ); assert!(wrap_words("", 10).is_empty()); } } #[c...
rust_dataset_chunk_511211
rust_dataset.txt
511,211
512
Attention::build( "here", vec![ ("here".to_owned(), Default::default()), session("api", 1), session("web", 2), ], )); state.inbox.tab = BrowserTab::Inbox; state.inbox.tab_chosen = true; state.render_plugi...
rust_dataset_chunk_511212
rust_dataset.txt
511,212
512
88); assert!(state.inbox.live_view_sent.is_some()); } fn only_web_is_left() -> GlobalAttention { let mut attention = SessionAttention::default(); let item = attention_item("web", 2); attention.counts.add(&item.attention); attention.items.push(item); GlobalAttent...
rust_dataset_chunk_511213
rust_dataset.txt
511,213
512
state.inbox.tab, BrowserTab::Inbox); assert!(state.inbox.is_selected(&api)); state.update(Event::Visible(false)); state.show_app_panel_view(Some("auto")); assert_eq!( state.inbox.tab, BrowserTab::Sessions, "a fresh open with nothing left shows the sess...
rust_dataset_chunk_511214
rust_dataset.txt
511,214
512
mut state = browser(); state.update(Event::GlobalAttentionUpdate(with_attention_off( only_web_is_left(), ))); state.update(Event::GlobalAttentionUpdate(only_web_is_left())); assert!(state.shows_browser_tabs()); state.show_app_panel_view(Some("inbox")); assert...
rust_dataset_chunk_511215
rust_dataset.txt
511,215
512
let mut state = browser(); let hints = state.inbox_hints(true); let keys: Vec<&str> = hints.iter().map(|hint| hint.key.as_str()).collect(); assert!(keys.contains(&"<ENTER>")); assert!(keys.contains(&inbox::TYPE_KEY)); assert!(keys.contains(&"<click the view>")); assert!(...
rust_dataset_chunk_511216
rust_dataset.txt
511,216
512
assert!(state.inbox.is_selected(&api)); let (line, column) = row_of(&state, &api); assert!(state.handle_inbox_key(alt_enter())); report(&mut state, true, None); assert!(state.handle_inbox_mouse(Mouse::LeftClick(line, column))); report(&mut state, false, Some(LiveViewRelea...
rust_dataset_chunk_511217
rust_dataset.txt
511,217
512
assert_eq!( state.panel.size, Some(PanelSize::Manager), "the first click does not go to the pane" ); let (line, column) = row_of(&state, &web); assert!(state.handle_inbox_mouse(Mouse::LeftClick(line, column))); assert_eq!(state.inbox.capture_ta...
rust_dataset_chunk_511218
rust_dataset.txt
511,218
512
!(state.handle_inbox_mouse(Mouse::ScrollUp(1))); assert!(state.inbox.is_selected(&key_of("api", 1))); } } #[cfg(test)] mod sessions_live_view_tests { use super::*; const ROWS: usize = 30; const COLS: usize = 120; fn pane(id: u32, title: &str, focused: bool, is_plugin: bool) -> SessionPrev...
rust_dataset_chunk_511219
rust_dataset.txt
511,219
512
String, PaneId)> { state .inbox .live_view_sent .as_ref() .filter(|view| !view.target.session.is_empty()) .map(|view| (view.target.session.clone(), view.target.pane_id)) } fn hidden(state: &State) -> bool { state .inbox ...
rust_dataset_chunk_511220
rust_dataset.txt
511,220
512
(7), "the Recent heading is skipped" ); assert_eq!( state.selected_session(), Some(("old".to_owned(), false, false)) ); assert_eq!( shown(&state), None, "an exited session keeps its saved preview" ); ...
rust_dataset_chunk_511221
rust_dataset.txt
511,221
512
Terminal(7), tab_id: 0, tab_name: "tab".to_owned(), pane_title: "pane7".to_owned(), attention: PaneAttention { status: AttentionStatus::NeedsYou, text: "question".to_owned(), since_ms: 100, ..Default::default...
rust_dataset_chunk_511222
rust_dataset.txt
511,222
512
sessions_browser(); let layout = state.sessions_live_layout.expect("the view is drawn"); assert_eq!(state.inbox.live_view_hint_text(), inbox::TYPE_INTO_IT_HINT); assert!(state.handle_mouse(Mouse::LeftClick( (layout.top + 2) as isize, layout.box_x + 2 ))); ...
rust_dataset_chunk_511223
rust_dataset.txt
511,223
512
fn clicking_a_row_selects_it_and_clicking_it_again_attaches() { let mut state = sessions_browser(); state.tree_select(1); state.render_plugin(ROWS, COLS); let (api_line, api_column) = tree_row_target(&state, 0); assert!(state.handle_mouse(Mouse::LeftClick(api_line, api_column...
rust_dataset_chunk_511224
rust_dataset.txt
511,224
512
mut state = sessions_browser(); state.tree_move(1); state.tree_move(-1); state.render_plugin(ROWS, COLS); let (api_line, api_column) = tree_row_target(&state, 0); assert!(state.handle_mouse(Mouse::LeftClick(api_line, api_column))); assert_eq!(state.single_screen_state.se...
rust_dataset_chunk_511225
rust_dataset.txt
511,225
512
let mut exited = sessions_browser(); select(&mut exited, 3); assert!(exited.selected_session_is_exited()); assert_eq!(exited.handle_manager_key(&alt_enter), Some(false)); assert_eq!(exited.inbox.capture_target, None); } #[test] fn the_all_keys_list_says_how_to_type_i...
rust_dataset_chunk_511226
rust_dataset.txt
511,226
512
tree .rows .iter() .position(|row| row.session == "here") .expect("the current session is listed"); (state, index) } fn sent_resize_allowed(state: &State) -> Option<bool> { state .inbox .live_view_sent .as_ref()...
rust_dataset_chunk_511227
rust_dataset.txt
511,227
512
) .iter() .any(|hint| hint.key == "<y>")); state.handle_key(KeyWithModifier::new(BareKey::Char('n'))); assert!(!state.pending_delete_exited); assert_eq!(state.exited_session_count(), 1); let heading = state .panel .tree .rows ...
rust_dataset_chunk_511228
rust_dataset.txt
511,228
512
Name, EnteringLayoutSearch, } impl Default for EnteringState { fn default() -> Self { EnteringState::EnteringName } } impl NewSessionInfo { pub fn name(&self) -> &str { &self.name } pub fn layout_search_term(&self) -> &str { &self.layout_list.layout_search_term } ...
rust_dataset_chunk_511229
rust_dataset.txt
511,229
512
.has_no_modifiers() => { self.move_selection_up(); }, BareKey::Down if key.has_no_modifiers() => { self.move_selection_down(); }, _ => {}, } } pub fn handle_selection(&mut self, current_session_name: &Option<String>) { ...
rust_dataset_chunk_511230
rust_dataset.txt
511,230
512
>, bool)> { // (layout_info, // search_indices, // is_selected) if self.is_searching() { self.layout_search_results(max_rows) .into_iter() .map(|(layout_search_result, is_selected)| { ( layout_search_...
rust_dataset_chunk_511231
rust_dataset.txt
511,231
512
{ // honestly, this is just the UX choice that sucks the least... self.clear_selection(); } } pub fn selected_layout_info(&self) -> Option<LayoutInfo> { if !self.layout_search_term.is_empty() { self.layout_search_results .get(self.selected_lay...
rust_dataset_chunk_511232
rust_dataset.txt
511,232
512
} fn layout_list_to_render(&self, max_rows: usize) -> Vec<(LayoutInfo, Vec<usize>, bool)> { let range_to_render = range_to_render( max_rows, self.layout_list.len(), Some(self.selected_layout_index), ); self.layout_list .iter() .enu...
rust_dataset_chunk_511233
rust_dataset.txt
511,233
512
= LayoutList::default(); ll.layout_list = names.iter().map(|n| make_layout(n)).collect(); ll } // --------------------------------------------------------------- // Section 6: Layout List Navigation // --------------------------------------------------------------- #[test] fn ...
rust_dataset_chunk_511234
rust_dataset.txt
511,234
512
_5_layout_viewport_windowing() { let mut ll = make_layout_list(&[ "layout-0", "layout-1", "layout-2", "layout-3", "layout-4", "layout-5", "layout-6", "layout-7", "layout-8", "layout-9", ]); ll.selected_layout_index = 5; let rendered = ll.layouts_to_render(5); ...
rust_dataset_chunk_511235
rust_dataset.txt
511,235
512
Some(19)); assert_eq!(start, 17); assert_eq!(end, 22); } #[test] fn test_7_4_viewport_clamps_at_top() { // table_rows=6, results_len=20, selected=0 // row_count_to_render = 5, half = 2 // first = 0.saturating_sub(2) = 0, last = 0+5 = 5 let (start, end) = ran...
rust_dataset_chunk_511236
rust_dataset.txt
511,236
512
{ pub columns: usize, pub rows: usize, pub viewport_columns: usize, pub viewport_rows: usize, } #[derive(Default)] pub struct Panel { pub size: Option<PanelSize>, pub is_popup: bool, pub popup_focused: bool, pub needs_initial_layout: bool, pub suggestions: Option<SessionSuggestions...
rust_dataset_chunk_511237
rust_dataset.txt
511,237
512
), PanMove::Down => self.rows_up = self.rows_up.saturating_sub(PREVIEW_PAN_ROWS), PanMove::PageUp => self.rows_up = self.rows_up.saturating_add(page), PanMove::PageDown => self.rows_up = self.rows_up.saturating_sub(page), PanMove::Left => self.columns = self.columns.satur...
rust_dataset_chunk_511238
rust_dataset.txt
511,238
512
| l.to_owned()).collect(); while lines .last() .map(|line| strip_ansi(line).trim().is_empty()) .unwrap_or(false) { lines.pop(); } lines } pub fn pan_move_for_key(key: &KeyWithModifier) -> Option<PanMove> { if !key.has_only_modifiers(&[KeyModifier::Shift]) { r...
rust_dataset_chunk_511239
rust_dataset.txt
511,239
512
() .collect() } pub fn card_resumable_count(&self) -> usize { self.card_candidates().filter(|s| !s.is_running).count() } pub fn card_empty_text(&self) -> &'static str { if self.card_resumable_count() > 0 { CARD_NO_LIVE_TEXT } else { CARD_EMPT...
rust_dataset_chunk_511240
rust_dataset.txt
511,240
512
Coordinates::default() .with_x_fixed(columns.saturating_sub(width)) .with_y_fixed(1) .with_width_fixed(width) .with_height_fixed(height) } pub fn apply_size(&mut self, size: PanelSize) { let own_pane = self.own_plugin_id.map(PaneId::Plugin); match...
rust_dataset_chunk_511241
rust_dataset.txt
511,241
512
2 + graphemes::display_width(&self.show_all_text()) }, None => graphemes::display_width(&self.show_all_text()), }; let content_width = table .width .max(graphemes::display_width(&self.card_empty_text())) .max(footer_width + ...
rust_dataset_chunk_511242
rust_dataset.txt
511,242
512
self.preview_pan.reset(); } self.preview_pane_id = pane_id; if session_changed { self.preview = None; self.saved_preview = None; } self.preview_session = Some(name.to_owned()); self.preview_tab = tab; self.preview_pane = pane; ...
rust_dataset_chunk_511243
rust_dataset.txt
511,243
512
while graphemes::display_width(&candidate) > max_width && shortened.len() > 1 { shortened.remove(0); candidate = format!("…/{}", shortened.join("/")); } if graphemes::display_width(&candidate) > max_width { candidate = graphemes::truncate_start(&candidate, max_width, "…").into_owned(...
rust_dataset_chunk_511244
rust_dataset.txt
511,244
512
_table( suggestions: &[SessionSuggestion], columns: Vec<SessionSuggestionColumn>, max_width: usize, context_branch: Option<&str>, ) -> CardTable { let mut columns = card_columns(&columns); let mut path_width = 24; loop { let table = layout_card_grid(suggestions, &columns, path_width,...
rust_dataset_chunk_511245
rust_dataset.txt
511,245
512
_else(|| "—".to_owned()), fact => s.fact_value(fact).unwrap_or_else(|| "—".to_owned()), }; let matches = s.column_matches(&column.fact); let level = match column.fact.as_str() { "directory" if matches => Some(1), "git_branch" if matches...
rust_dataset_chunk_511246
rust_dataset.txt
511,246
512
) { use crate::session_tree::TreeNode; use crate::ui::components::CachedRowKind; panel.tree.row_targets.clear(); panel.tree.marker_targets.clear(); let sessions: Vec<(usize, String, bool)> = cache .rows .iter() .map(|r| { ( r.original_index, ...
rust_dataset_chunk_511247
rust_dataset.txt
511,247
512
_name)); let mut text = format!("{} {}", marker, row.session_name); if current_session.as_deref() == Some(row.session_name.as_str()) { text.push(' '); text.push_str(CURRENT_SESSION_LABEL); } else if previous_session.as_deref() == Some(row.session_name.as_str()) { ...
rust_dataset_chunk_511248
rust_dataset.txt
511,248
512
abbreviate = total_session_width + 2 + 24 + 3 > max_cols; let header_x = x + 3 + name_width + 2; print_text_with_coordinates(Text::from("Folder").dim_all(), header_x, y, None, None); print_text_with_coordinates( Text::from("Branch").dim_all(), header_x + folder_width + 2, y, ...
rust_dataset_chunk_511249
rust_dataset.txt
511,249
512
.filter(|&&i| i < name_len) .map(|i| i + 2) .collect(); if !indices.is_empty() { text = text.color_indices(3, indices); } let name_chars = name.chars().count(); if previous_session.as_deref() == ...
rust_dataset_chunk_511250
rust_dataset.txt
511,250
512
.map(|t| t.active).unwrap_or(false); let status = top_status( attention .iter() .flat_map(|g| g.items.iter()) .filter(|i| i.session == row.session && i.item.tab_name == name), ); l...
rust_dataset_chunk_511251
rust_dataset.txt
511,251
512
.row_targets .push((row_y, x..x + max_cols, flat_index)); if row.expandable { panel .tree .marker_targets .push((row_y, x + row.depth * 2 + 1, flat_index)); } } print_nested_list_with_coordinates(items, x, y + 1,...
rust_dataset_chunk_511252
rust_dataset.txt
511,252
512
_plain(&title, inner_width.saturating_sub(1)); let filler = inner_width.saturating_sub(graphemes::display_width(&title)); let top = format!("┌{}{}┐", title, "─".repeat(filler)); let top_text = Text::from(top).color_range(2, 1..1 + title.chars().count()); print_text_with_coordinates(top_text, x, y, Some(...
rust_dataset_chunk_511253
rust_dataset.txt
511,253
512
= saved .tabs .iter() .flat_map(|t| t.panes.iter().filter_map(|p| p.command.clone())) .collect(); if !commands.is_empty() { details.push(Text::from("Commands that will run again:").color_range(2, ..)); for comma...
rust_dataset_chunk_511254
rust_dataset.txt
511,254
512
_sub(1)); let filler = inner_width.saturating_sub(1 + graphemes::display_width(&summary)); let summary_len = summary.chars().count(); Text::from(format!("└─{}{}┘", summary, "─".repeat(filler))) .dim_range(2..2 + summary_len) }, _ => Text::from(format!(...
rust_dataset_chunk_511255
rust_dataset.txt
511,255
512
), None, ); } fn push_fitting_clusters( pending: &mut String, result: &mut String, column: &mut usize, skip: usize, visible: &mut usize, width: usize, ) -> bool { let mut overflowed = false; for (cluster, cluster_width) in graphemes::clusters(pending) { if *column + ...
rust_dataset_chunk_511256
rust_dataset.txt
511,256
512
("\u{1b}["); while let Some(c) = chars.next() { sequence.push(c); if ('@'..='~').contains(&c) { break; } } if sequence.ends_with('m') { ...
rust_dataset_chunk_511257
rust_dataset.txt
511,257
512
display_width(text) <= max_width { return text.to_owned(); } let room = max_width.saturating_sub(1); let mut result = graphemes::truncate_end(text, room, "").into_owned(); result.push('…'); result } #[cfg(test)] mod tests { use super::*; fn suggestion(name: &str, running: bool, rel...
rust_dataset_chunk_511258
rust_dataset.txt
511,258
512
Folder", "Branch", " "]); assert_eq!(row_text(&table, 1), vec!["api", "zellij", "main", "2m ago"]); } #[test] fn the_table_width_includes_the_space_after_every_column() { let table = build_card_table( &[suggestion("api", true, FolderRelation::Here)], vec![], ...
rust_dataset_chunk_511259
rust_dataset.txt
511,259
512
.facts.insert( "project".to_owned(), "an-extremely-long-project-value-here".to_owned(), ); let table = build_card_table( &[s], vec![SessionSuggestionColumn { fact: "project".to_owned(), title: "project".to_owned(), ...
rust_dataset_chunk_511260
rust_dataset.txt
511,260
512
", true, FolderRelation::Other) }; let neither = SessionSuggestion { name: "neither".to_owned(), is_running: true, ..Default::default() }; let panel = panel_with(vec![no_folder, no_branch, neither]); let listed = panel.card_suggestions(); ...
rust_dataset_chunk_511261
rust_dataset.txt
511,261
512
1 + 1 + 4 + 2 * CARD_PADDING); } #[test] fn scrolling_keeps_a_margin_around_the_selection() { assert_eq!(scroll_with_margin(0, 0, 5, 20, 2), 0); assert_eq!(scroll_with_margin(0, 2, 5, 20, 2), 0); assert_eq!(scroll_with_margin(0, 3, 5, 20, 2), 1); assert_eq!(scroll_with_marg...
rust_dataset_chunk_511262
rust_dataset.txt
511,262
512
assert_eq!(strip_ansi(&fitted), format!("a{}", family)); let fitted = fit_ansi(&format!("ab{}", family), 3); assert_eq!(strip_ansi(&fitted), "ab "); let fitted = fit_ansi("ae\u{301}b", 2); assert_eq!(strip_ansi(&fitted), "ae\u{301}"); } #[test] fn plain_text_is_truncated_by...
rust_dataset_chunk_511263
rust_dataset.txt
511,263
512
::Up, 0); let window = pan.place(&lines, 2, 10); assert_eq!(window.start, 0); assert!(window.panned); pan.apply(PanMove::Down, 0); assert_eq!(pan.place(&lines, 2, 10).start, 3); pan.apply(PanMove::Top, 1); assert_eq!(pan.place(&lines, 2, 10).start, 1); let...
rust_dataset_chunk_511264
rust_dataset.txt
511,264
512
2, ..7); let table_rows = rows.saturating_sub(5); // search row, toggle row and some padding let table_columns = columns; let table = if self.is_searching { self.render_search_results(table_rows, columns) } else { self.render_all_entries(table_rows, columns) ...
rust_dataset_chunk_511265
rust_dataset.txt
511,265
512
== self.selected_index; let mut table_cells = vec![ self.render_session_name(&session.0, None), self.render_ctime(&session.1), self.render_more_indication_or_enter_as_needed( i, first_row_index_t...
rust_dataset_chunk_511266
rust_dataset.txt
511,266
512
_render / 2); let last_row_index_to_render = first_row_index_to_render + row_count_to_render; (first_row_index_to_render, last_row_index_to_render) } else { let first_row_index_to_render = 0; let last_row_index_to_render = results_len; (first_row_index...
rust_dataset_chunk_511267
rust_dataset.txt
511,267
512
(&mut self) { if self.is_searching { if let Some(selected_index) = self.selected_search_index.as_mut() { if *selected_index == self.search_results.len().saturating_sub(1) { *selected_index = 0; } else { *selected_index = *select...
rust_dataset_chunk_511268
rust_dataset.txt
511,268
512
_search_index .and_then(|i| self.search_results.get(i)) { let _ = delete_dead_session(&search_result.session_name); } } else if let Some(session_name_and_creation_time) = self.selected_index.and_then(|i| { if self.all_resurrectable_sessions.len...
rust_dataset_chunk_511269
rust_dataset.txt
511,269
512
} matches.sort_by(|a, b| b.score.cmp(&a.score)); self.search_results = matches; self.is_searching = !self.search_term.is_empty(); match self.selected_search_index { Some(search_index) => { if self.search_results.is_empty() { self.se...
rust_dataset_chunk_511270
rust_dataset.txt
511,270
512
_session) in flattened_assets.drain(..) { if let Some((score, indices)) = matcher.fuzzy_indices(&list_item.name, &search_term) { matches.push(SearchResult::new( score, indices, list_item, sess...
rust_dataset_chunk_511271
rust_dataset.txt
511,271
512
_index .and_then(|i| self.search_results.get(i)) .map(|s| s.is_current_session) .unwrap_or(false) } else { self.selected_index .0 .and_then(|i| self.session_ui_infos.get(i)) .map(|s_i| s_i.is_current_sess...
rust_dataset_chunk_511272
rust_dataset.txt
511,272
512
}, SelectedIndex(Some(selected_session), None, None) => { if self.session_ui_infos.len() > selected_session + 1 { self.selected_index.0 = Some(selected_session + 1); } else { self.selected_index.0 = N...
rust_dataset_chunk_511273
rust_dataset.txt
511,273
512
self .get_session(selected_session) .map(|s| s.tabs.len()) .unwrap_or(0); self.selected_index.1 = Some(tab_count.saturating_sub(1)) } }, SelectedIndex(Some(sel...
rust_dataset_chunk_511274
rust_dataset.txt
511,274
512
Some(self.search_results.len()) { self.selected_search_index = None; } } } pub fn reset_selected_index(&mut self) { self.selected_index.reset(); } /// After deleting one or more entries (and re-running `update_search_term` /// to rebuild `sear...
rust_dataset_chunk_511275
rust_dataset.txt
511,275
512
. Returns the same /// numeric row when it still exists (so the cursor lands on whatever entry /// took the deleted row's slot), the last index when the deletion happened /// at the tail, or `None` when the list is now empty. pub fn clamp_index_after_delete(prev_index: Option<usize>, new_len: usize) -> Option<usize> { ...
rust_dataset_chunk_511276
rust_dataset.txt
511,276
512
lines_to_render(&self) -> usize { self.list_item.line_count() } pub fn render(&self, max_width: usize) -> Vec<LineToRender> { self.list_item.render(Some(self.indices.clone()), max_width) } } --- FILE: zellij/default-plugins/session-manager/src/session_tree.rs --- use std::collections::{BT...
rust_dataset_chunk_511277
rust_dataset.txt
511,277
512
ed(&sessions, false, 0) } pub fn flatten_grouped( &self, sessions: &[(usize, String, bool)], expand_exited: bool, recent: usize, ) -> Vec<TreeRow> { let mut rows = vec![]; for (original_index, name, _) in sessions.iter().filter(|(_, _, exited)| !exited) { ...
rust_dataset_chunk_511278
rust_dataset.txt
511,278
512
}); if !expanded { return; } let Some(tabs) = children else { return; }; for (tab_index, tab) in tabs.iter().enumerate() { let tab_expanded = self.expanded_tabs.contains(&(name.to_owned(), tab_index)); rows.push(TreeRow { ...
rust_dataset_chunk_511279
rust_dataset.txt
511,279
512
} pub fn identity(&self, index: usize) -> Option<(String, TreeNode)> { self.rows .get(index) .map(|row| (row.session.clone(), row.node)) } pub fn set_children_from_tabs(&mut self, session: &str, tabs: &[SessionPreviewTab]) -> bool { let tabs: Vec<TreeTab> = tabs...
rust_dataset_chunk_511280
rust_dataset.txt
511,280
512
}, TreeNode::Tab(tab_index) => { let panes = &tabs.get(tab_index)?.panes; let pane_index = panes .iter() .position(|pane| pane.focused && !pane.is_plugin) .or_else(|| panes.iter().position(|pane| !pane.is...
rust_dataset_chunk_511281
rust_dataset.txt
511,281
512
_from_tabs("api", &tabs())); assert!(!tree.set_children_from_tabs("api", &tabs())); let rows = tree.flatten(&sessions()); tree.toggle(&rows[0]); let rows = tree.flatten(&sessions()); let nodes: Vec<TreeNode> = rows.iter().map(|r| r.node).collect(); assert_eq!( ...
rust_dataset_chunk_511282
rust_dataset.txt
511,282
512
assert_eq!(tree.cursor_position(&rows, Some(3)), Some(2)); tree.toggle(&rows[2]); let rows = tree.flatten_grouped(&sessions, false, 0); let shown: Vec<(&str, usize)> = rows.iter().map(|r| (r.session.as_str(), r.depth)).collect(); assert_eq!( shown, ve...
rust_dataset_chunk_511283
rust_dataset.txt
511,283
512
, vec![ TreeNode::Session, TreeNode::Recent, TreeNode::Session, TreeNode::Session ], "with three or fewer exited sessions there is no folded group" ); } #[test] fn a_session_without_tabs_cannot_be_ex...
rust_dataset_chunk_511284
rust_dataset.txt
511,284
512
()), ..Default::default() }; assert!(!tree.set_children_from_saved(&failed)); } fn pane(id: u32, title: &str, focused: bool, is_plugin: bool) -> SessionPreviewPane { SessionPreviewPane { id, title: title.to_owned(), focused, is...
rust_dataset_chunk_511285
rust_dataset.txt
511,285
512
assert_eq!(tree.live_pane("api", TreeNode::Pane(0, 1)), Some((0, 1, 2))); let mut without_clients = mixed_tabs(); for tab in without_clients.iter_mut() { tab.active = false; } tree.set_children_from_tabs("quiet", &without_clients); assert_eq!( tree.live_p...
rust_dataset_chunk_511286
rust_dataset.txt
511,286
512
Mode::SearchAndSelect } } #[derive(Debug)] pub enum UnifiedSearchResult { ActiveSession { score: i64, indices: Vec<usize>, session_name: String, connected_users: usize, tab_count: usize, pane_count: usize, is_current_session: bool, creation_time: ...
rust_dataset_chunk_511287
rust_dataset.txt
511,287
512
, .. }, UnifiedSearchResult::ResurrectableSession { ctime: ct_b, .. }, ) => ct_a.cmp(ct_b), ( UnifiedSearchResult::ActiveSession { .. }, UnifiedSearchResult::ResurrectableSession { .. }, ) => std::cmp::Ordering::Less, ( ...
rust_dataset_chunk_511288
rust_dataset.txt
511,288
512
_by(|a, b| a.cmp_by_type_then_recency(b)), } } else { self.unified_results = self.collect_fuzzy_matched_sessions(active_sessions, resurrectable_sessions); self.unified_results.sort_by(|a, b| { let score_cmp = b.score().cmp(&a.score()); ...
rust_dataset_chunk_511289
rust_dataset.txt
511,289
512
results } fn collect_fuzzy_matched_sessions( &mut self, active_sessions: &[SessionUiInfo], resurrectable_sessions: &[(String, Duration)], ) -> Vec<UnifiedSearchResult> { let matcher = self .fuzzy_matcher .get_or_insert_with(|| SkimMatcherV2::default(...
rust_dataset_chunk_511290
rust_dataset.txt
511,290
512
; if !self.is_current_session(candidate) { return Some(candidate); } } None } pub fn move_selection_down(&mut self) { if self.unified_results.is_empty() { return; } match self.selected_index { None => { ...
rust_dataset_chunk_511291
rust_dataset.txt
511,291
512
| r.session_name() == name); self.tab_cycle = Some(cycle); } fn start_tab_cycle(&self, forward: bool) -> Option<TabCycle> { let candidates: Vec<String> = self .unified_results .iter() .filter(|r| { !matches!( r, ...
rust_dataset_chunk_511292
rust_dataset.txt
511,292
512
: bool, creation_secs: u64, ) -> SessionUiInfo { SessionUiInfo { name: name.to_string(), tabs: (0..tabs) .map(|i| crate::ui::TabUiInfo { name: format!("tab-{}", i), panes: (0..panes_per_tab) .map(...
rust_dataset_chunk_511293
rust_dataset.txt
511,293
512
let resurrectable = vec![ make_resurrectable("res-300", 300), make_resurrectable("res-100", 100), make_resurrectable("res-200", 200), ]; state.update_search_term(&[], &resurrectable); assert_eq!(state.unified_results.len(), 3); assert_eq!(state.unifie...
rust_dataset_chunk_511294
rust_dataset.txt
511,294
512
2); // Current session should be present (filtering is done in renderer) let has_current = state.unified_results.iter().any(|r| match r { UnifiedSearchResult::ActiveSession { is_current_session, .. } => *is_current_session, _ => false, }); ...
rust_dataset_chunk_511295
rust_dataset.txt
511,295
512
1, 1, 1, false, 100), make_active_session("beta", 1, 1, 1, false, 200), make_active_session("gamma", 1, 1, 1, false, 300), ]; state.search_term = "alp".to_string(); state.update_search_term(&active, &[]); assert_eq!(state.unified_results.len(), 1); assert_...
rust_dataset_chunk_511296
rust_dataset.txt
511,296
512
64> = state .unified_results .iter() .map(|r| match r { UnifiedSearchResult::ActiveSession { score, .. } => *score, UnifiedSearchResult::ResurrectableSession { score, .. } => *score, }) .collect(); for i in 0..scores.len...
rust_dataset_chunk_511297
rust_dataset.txt
511,297
512
pos_b = state .unified_results .iter() .position(|r| r.session_name() == "test-b"); if let (Some(a), Some(b)) = (pos_a, pos_b) { // If scores are equal, test-b should come first (more recent) let score_a = match &state.unified_results[a] { ...
rust_dataset_chunk_511298
rust_dataset.txt
511,298
512
".to_string(); state.update_search_term(&active, &[]); // "beta" does not contain "a" in a way that fuzzy matches well. // Check: if beta is not in results, selected_index should be None let beta_still_present = state .unified_results .iter() .any(|r| ...
rust_dataset_chunk_511299
rust_dataset.txt
511,299
512
state.move_selection_down(); assert_eq!(state.selected_index, Some(0)); // wraps, skips current at 1 } #[test] fn test_3_3_up_from_none_selects_last_non_current() { let mut state = SingleScreenState::default(); setup_results_with_current( &mut state, &[("oth...