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_519700 | rust_dataset.txt | 519,700 | 512 | 0, SessionState::Running);
assert_eq!(no_branch.1.branch, None);
let no_context = &found["no-context"];
assert_eq!(no_context.0, SessionState::Resumable);
assert_eq!(no_context.1.folder, None);
assert_eq!(no_context.1.branch, None);
}
#[test]
fn outside_git_only_fold... |
rust_dataset_chunk_519701 | rust_dataset.txt | 519,701 | 512 | ::from("/home/me/project/")));
drop(index);
let later = cache_dir.join("later");
std::fs::create_dir_all(&later).unwrap();
std::fs::write(later.join(SESSION_LAYOUT_FILE_NAME), "layout {\n}\n").unwrap();
let index = SessionIndex::open(
&root.path().join("index.sqlite")... |
rust_dataset_chunk_519702 | rust_dataset.txt | 519,702 | 512 | State::Running,
},
tier: None,
matching_facts: vec![],
script_label: None,
}
}
#[test]
fn script_order_puts_listed_sessions_first() {
let builtin = vec![ranked("a"), ranked("b"), ranked("c")];
let output = vec![
("c".to_own... |
rust_dataset_chunk_519703 | rust_dataset.txt | 519,703 | 512 | work".to_owned())
);
}
#[test]
fn registering_a_known_session_again_keeps_its_id() {
let test = TestIndex::new();
let id = test.index.register("work", 10).unwrap();
test.mark_resumable(&id);
assert_eq!(test.index.register("work", 20).unwrap(), id);
}
#[test]... |
rust_dataset_chunk_519704 | rust_dataset.txt | 519,704 | 512 | }
#[test]
fn renaming_keeps_the_id_and_frees_the_old_name() {
let test = TestIndex::new();
let id = test.index.register("before", 10).unwrap();
test.index.rename_by_id(&id, "after", 20).unwrap();
assert_eq!(test.index.session_id("after").unwrap(), Some(id.clone()));
... |
rust_dataset_chunk_519705 | rust_dataset.txt | 519,705 | 512 | TestIndex::new();
let id = test.index.register("work", 10).unwrap();
test.mark_running(&id);
test.mark_running("legacy");
let mut names = test.index.running_session_names();
names.sort();
assert_eq!(names, vec!["legacy".to_owned(), "work".to_owned()]);
}
#[test]... |
rust_dataset_chunk_519706 | rust_dataset.txt | 519,706 | 512 | --- FILE: zellij/zellij-utils/src/session_link.rs ---
use crate::attention::SessionAttention;
use crate::input::actions::Action;
use crate::ipc::{
ClientToServerMsg, IpcReceiverWithContext, IpcSenderWithContext, ServerToClientMsg,
};
use std::collections::HashMap;
use std::path::Path;
use std::sync::mpsc::{channel,... |
rust_dataset_chunk_519707 | rust_dataset.txt | 519,707 | 512 | Result<ServerToClientMsg, String> {
let _ = self.receiver.set_read_timeout(None);
self.receiver
.try_recv_server_msg()
.map(|(msg, _)| msg)
.map_err(|e| e.to_string())
}
pub fn recv(&mut self, timeout: Duration) -> Result<ServerToClientMsg, String> {
... |
rust_dataset_chunk_519708 | rust_dataset.txt | 519,708 | 512 | is_err() {
return false;
}
matches!(link.recv(timeout), Ok(ServerToClientMsg::Connected))
}
pub fn stop_session(session_name: &str, timeout: Duration) -> Result<(), String> {
let mut link = match SessionLink::connect(&crate::consts::session_socket_path(session_name)) {
Ok(link) => link,
... |
rust_dataset_chunk_519709 | rust_dataset.txt | 519,709 | 512 | struct RemoteActions {
queues: Arc<Mutex<HashMap<String, RemoteActionQueue>>>,
next_generation: u64,
}
impl RemoteActions {
pub fn send(&mut self, session_name: &str, actions: Vec<Action>) {
let Ok(mut queues) = self.queues.lock() else {
return;
};
let actions = match q... |
rust_dataset_chunk_519710 | rust_dataset.txt | 519,710 | 512 | _queue(&queues, &session_name, generation, &receiver) {
Some(late) => late,
None => return,
}
},
};
while let Ok(more) = receiver.try_recv() {
batch.extend(more);
}
if let Err(e) = send_actions_to_session(&se... |
rust_dataset_chunk_519711 | rust_dataset.txt | 519,711 | 512 | eps_its_queue_when_an_old_one_leaves() {
let queues: Arc<Mutex<HashMap<String, RemoteActionQueue>>> = Default::default();
let (old_sender, old_receiver) = channel::<Vec<Action>>();
drop(old_sender);
let (sender, _receiver) = channel();
queues.lock().unwrap().insert(
"... |
rust_dataset_chunk_519712 | rust_dataset.txt | 519,712 | 512 | _muted: bool,
pub ignore_output: bool,
}
pub fn serialize_session_layout(
global_layout_manifest: GlobalLayoutManifest,
) -> Result<(String, BTreeMap<String, String>), &'static str> {
// BTreeMap is the pane contents and their file names
let mut document = KdlDocument::new();
let mut pane_contents ... |
rust_dataset_chunk_519713 | rust_dataset.txt | 519,713 | 512 | {
let floating_panes_layout = get_floating_panes_layout_from_panegeoms(floating_panes);
let tiled_panes = tiled_panes_to_serialize(tiled_panes_layout);
serialized_tab
.entries_mut()
.push(KdlEntry::new_prop("name", tab_name));
if is_focuse... |
rust_dataset_chunk_519714 | rust_dataset.txt | 519,714 | 512 | _split_direction != &SplitDirection::default()
|| root.children_are_stacked
{
vec![root]
} else {
root.children
}
}
fn serialize_tiled_and_floating_panes(
tiled_panes: &Vec<TiledPaneLayout>,
floating_panes_layout: Vec<FloatingPaneLayout>,
pane_contents: &mut BTreeMap<Str... |
rust_dataset_chunk_519715 | rust_dataset.txt | 519,715 | 512 | _fg {
tiled_pane_node
.entries_mut()
.push(KdlEntry::new_prop("default_fg", fg.to_owned()));
}
if let Some(ref bg) = layout.default_bg {
tiled_pane_node
.entries_mut()
.push(KdlEntry::new_prop("default_bg", bg.to_owned()));
}
serialize_atte... |
rust_dataset_chunk_519716 | rust_dataset.txt | 519,716 | 512 | (
Some(run_plugin.location.display()),
Some(run_plugin.configuration.clone()),
),
RunPluginOrAlias::Alias(plugin_alias) => {
// in this case, the aliases should already be populated by the RunPlugins they
// translate to - if they ... |
rust_dataset_chunk_519717 | rust_dataset.txt | 519,717 | 512 | _dollar_signs(&path)));
}
}
if focus.unwrap_or(false) {
kdl_node
.entries_mut()
.push(KdlEntry::new_prop("focus", KdlValue::Bool(true)));
}
if let Some(initial_pane_contents) = initial_pane_contents.as_ref() {
if command.is_none() && edit.is_none() {
... |
rust_dataset_chunk_519718 | rust_dataset.txt | 519,718 | 512 | ()
.push(KdlEntry::new_prop("size", KdlValue::Base10(size as i64))),
Some(SplitSize::Percent(size)) => kdl_node
.entries_mut()
.push(KdlEntry::new_prop("size", format!("{size}%"))),
None => (),
};
}
if layout.borderless.unwrap_or(fa... |
rust_dataset_chunk_519719 | rust_dataset.txt | 519,719 | 512 | _mut().push(node);
},
None => {},
}
match layout.width {
Some(PercentOrFixed::Fixed(fixed_width)) => {
let mut node = KdlNode::new("width");
node.entries_mut()
.push(KdlEntry::new(KdlValue::Base10(fixed_width as i64)));
pane_node_childr... |
rust_dataset_chunk_519720 | rust_dataset.txt | 519,720 | 512 | )));
pane_node_children.nodes_mut().push(node);
}
if let Some(border_style) = layout.border_style.as_ref() {
for (property_name, value) in border_style_properties(border_style) {
let mut node = KdlNode::new(property_name);
node.entries_mut().push(KdlEntry::new(value));
... |
rust_dataset_chunk_519721 | rust_dataset.txt | 519,721 | 512 | new_tab_template {
let tiled_panes = tiled_panes_to_serialize(tiled_panes);
let mut new_tab_template_node = KdlNode::new("new_tab_template");
let mut new_tab_template_children = KdlDocument::new();
serialize_tiled_and_floating_panes(
&tiled_panes,
floating_panes... |
rust_dataset_chunk_519722 | rust_dataset.txt | 519,722 | 512 | Entry::new_prop(
"max_panes",
KdlValue::Base10(max_panes as i64),
)),
LayoutConstraint::MinPanes(min_panes) => Some(KdlEntry::new_prop(
"min_panes",
KdlValue::Base10(min_panes as i64),
)),
LayoutConstraint::ExactPanes(exact_panes) => Some(K... |
rust_dataset_chunk_519723 | rust_dataset.txt | 519,723 | 512 | Map<String, String>,
) -> Result<Vec<KdlNode>, &'static str> {
let mut serialized_tabs: Vec<KdlNode> = vec![];
for (tab_name, tab_layout_manifest) in tabs {
let tiled_panes = tab_layout_manifest.tiled_panes;
let floating_panes = tab_layout_manifest.floating_panes;
let hide_floating_panes... |
rust_dataset_chunk_519724 | rust_dataset.txt | 519,724 | 512 | serialize_floating_layout_attributes(&layout, &mut floating_pane_node_children);
serialize_args(args, &mut floating_pane_node_children);
serialize_plugin(plugin, plugin_config, &mut floating_pane_node_children);
floating_pane_node.set_children(floating_pane_node_children);
floating_pane_node
}
fn s... |
rust_dataset_chunk_519725 | rust_dataset.txt | 519,725 | 512 | <SplitSize>,
) -> TiledPaneLayout {
let (
run,
borderless,
is_expanded_in_stack,
name,
focus,
pane_initial_contents,
default_fg,
default_bg,
border_style,
attention_muted,
ignore_output,
) = manifest
.map(|g| {
... |
rust_dataset_chunk_519726 | rust_dataset.txt | 519,726 | 512 | new_constraints = Vec::new();
for i in 1..splits.len() {
let (v_min, v_max) = (splits[i - 1], splits[i]);
let subgeoms: Vec<PaneLayoutManifest>;
(subgeoms, remaining_geoms) = match children_split_direction {
SplitDirection::Horizontal => remaining_geoms
.clone()
... |
rust_dataset_chunk_519727 | rust_dataset.txt | 519,727 | 512 | manifests
.iter()
.map(|m| {
let mut run = m.run.clone();
if let Some(cwd) = &m.cwd {
run.as_mut().map(|r| r.add_cwd(cwd));
}
FloatingPaneLayout {
name: m.title.clone(),
height: Some(at_least_one(m.geom.rows... |
rust_dataset_chunk_519728 | rust_dataset.txt | 519,728 | 512 | /// perpendicular the `SplitDirection`, for which there is a split spanning
/// the max_cols or max_rows of the domain. The values are ordered
/// increasingly and contains the boundaries of the domain.
fn get_splits(geoms: &Vec<PaneLayoutManifest>) -> Option<(SplitDirection, Vec<usize>)> {
if geoms.len() == 1 {
... |
rust_dataset_chunk_519729 | rust_dataset.txt | 519,729 | 512 | )
.map(|g| g.geom.rows.as_usize())
.sum::<usize>()
== max_rows
{
splits.push(x);
};
}
splits.push(*x_max); // Necessary as `g.x` is from the upper-left corner
splits
}
/// Returns a vector containing the coordinate (y) of the rows that split t... |
rust_dataset_chunk_519730 | rust_dataset.txt | 519,730 | 512 | )
.map(|g| g.geom.cols.as_usize())
.sum::<usize>()
== max_cols
{
splits.push(y);
};
}
splits.push(*y_max); // Necessary as `g.y` is from the upper-left corner
splits
}
/// Get the constraint of the domain considered, base on the rows or column... |
rust_dataset_chunk_519731 | rust_dataset.txt | 519,731 | 512 | += size;
}
y += geom.geom.rows.as_usize();
},
None => {
return None;
},
}
}
if percent == 0.0 {
Some(Constraint::Fixed(y_max - y_min))
} else {
Some(Constraint::Percent(percent))
}
}
/// Returns... |
rust_dataset_chunk_519732 | rust_dataset.txt | 519,732 | 512 | )", "inner": 211 }, "is_stacked": false }"#,
],
&[
r#"{ "x": 0, "y": 0, "rows": { "constraint": "Percent(100.0)", "inner": 26 }, "cols": { "constraint": "Percent(100.0)", "inner": 211 }, "is_stacked": false }"#,
r#"{ "x": 0, "y": 26, "rows": { "constraint": "Fixed(20)", "inner": ... |
rust_dataset_chunk_519733 | rust_dataset.txt | 519,733 | 512 | "Fixed(40)", "inner": 40 }, "is_stacked": false }"#,
r#"{ "x": 0, "y": 36, "rows": { "constraint": "Fixed(10)", "inner": 10 }, "cols": { "constraint": "Percent(50.0)", "inner": 106 }, "is_stacked": false }"#,
r#"{ "x": 106, "y": 36, "rows": { "constraint": "Fixed(10)", "inner": 10 }, "cols": { ... |
rust_dataset_chunk_519734 | rust_dataset.txt | 519,734 | 512 | ": { "constraint": "Percent(30.0)", "inner": 63 }, "is_stacked": false }"#,
],
&[
r#"{ "x": 0, "y": 0, "rows": { "constraint": "Fixed(5)", "inner": 5 }, "cols": { "constraint": "Percent(100.0)", "inner": 211 }, "is_stacked": false }"#,
r#"{ "x": 0, "y": 5, "rows": { "constraint":... |
rust_dataset_chunk_519735 | rust_dataset.txt | 519,735 | 512 | let global_layout_manifest = GlobalLayoutManifest {
tabs: vec![("Tab #1".to_owned(), tab_layout_manifest)],
..Default::default()
};
let kdl = serialize_session_layout(global_layout_manifest).unwrap();
expect![[r#"
layout {
tab name="Tab #1" {
... |
rust_dataset_chunk_519736 | rust_dataset.txt | 519,736 | 512 | size="50%"
}
}
}
"#]]
.assert_eq(&kdl.0);
let geoms = PANEGEOMS_JSON[3]
.iter()
.map(|pg| parse_panegeom_from_json(pg))
.map(|geom| PaneLayoutManifest {
geom,
..Default::default(... |
rust_dataset_chunk_519737 | rust_dataset.txt | 519,737 | 512 | ("/path/to/m\"y/global cwd")),
..Default::default()
};
let kdl = serialize_session_layout(global_layout_manifest).unwrap();
assert_snapshot!(kdl.0);
}
#[test]
fn can_serialize_tab_with_a_single_tiled_pane() {
use crate::input::command::RunCommand;
let tab... |
rust_dataset_chunk_519738 | rust_dataset.txt | 519,738 | 512 | Dimension::fixed(5),
stacked: None,
is_pinned: false,
logical_position: None,
},
..Default::default()
}],
..Default::default()
};
let global_layout_manifest = GlobalLayoutManifest {
... |
rust_dataset_chunk_519739 | rust_dataset.txt | 519,739 | 512 | {
swap_tiled_layout name="my-swap" {
tab {
pane name="my-only-swap-pane"
}
}
}
"#]]
.assert_eq(&kdl.0);
}
#[test]
fn can_serialize_tab_name() {
let global_layout_manifest = G... |
rust_dataset_chunk_519740 | rust_dataset.txt | 519,740 | 512 | {
run: Some(Run::Cwd(PathBuf::from("/tmp/\"my/cool cwd"))),
geom: PaneGeom {
x: 0,
y: 10,
rows: Dimension::fixed(10),
cols: Dimension::fixed(10),
stacked: None... |
rust_dataset_chunk_519741 | rust_dataset.txt | 519,741 | 512 | ),
cols: Dimension::fixed(10),
stacked: None,
is_pinned: false,
logical_position: None,
},
..Default::default()
},
PaneLayoutManifest {
... |
rust_dataset_chunk_519742 | rust_dataset.txt | 519,742 | 512 | ());
let tab_layout_manifest = TabLayoutManifest {
floating_panes: vec![
PaneLayoutManifest {
geom: PaneGeom {
x: 0,
y: 0,
rows: Dimension::fixed(10),
cols: Dimension::... |
rust_dataset_chunk_519743 | rust_dataset.txt | 519,743 | 512 | false,
logical_position: None,
},
..Default::default()
},
PaneLayoutManifest {
run: Some(Run::Plugin(RunPluginOrAlias::RunPlugin(
RunPlugin::from_url("file:/tmp/\"my/cool cwd/plug... |
rust_dataset_chunk_519744 | rust_dataset.txt | 519,744 | 512 | let kdl = serialize_session_layout(global_layout_manifest).unwrap();
assert_snapshot!(kdl.0);
}
#[test]
fn can_serialize_tab_with_stacked_panes() {
let tab_layout_manifest = TabLayoutManifest {
tiled_panes: vec![
PaneLayoutManifest {
ge... |
rust_dataset_chunk_519745 | rust_dataset.txt | 519,745 | 512 | _position: None,
},
..Default::default()
},
PaneLayoutManifest {
geom: PaneGeom {
x: 0,
y: 11,
rows: Dimension::fixed(1),
cols: Dime... |
rust_dataset_chunk_519746 | rust_dataset.txt | 519,746 | 512 | : Dimension::fixed(10),
stacked: Some(0),
is_pinned: false,
logical_position: None,
},
..Default::default()
},
PaneLayoutManifest {
geom: PaneGeom {
... |
rust_dataset_chunk_519747 | rust_dataset.txt | 519,747 | 512 | inned: false,
logical_position: None,
},
..Default::default()
},
PaneLayoutManifest {
geom: PaneGeom {
x: 10,
y: 1,
rows: Dimension:... |
rust_dataset_chunk_519748 | rust_dataset.txt | 519,748 | 512 | kdl.0);
}
#[test]
fn can_serialize_multiple_tabs() {
let tab_1_layout_manifest = TabLayoutManifest {
tiled_panes: vec![PaneLayoutManifest {
geom: PaneGeom {
x: 0,
y: 0,
rows: Dimension::percent(100.0),
... |
rust_dataset_chunk_519749 | rust_dataset.txt | 519,749 | 512 | = serialize_session_layout(global_layout_manifest).unwrap();
assert_snapshot!(kdl.0);
}
#[test]
fn can_serialize_swap_tiled_panes() {
let tiled_panes_layout = TiledPaneLayout {
children: vec![TiledPaneLayout::default(), TiledPaneLayout::default()],
..Default::default... |
rust_dataset_chunk_519750 | rust_dataset.txt | 519,750 | 512 | MaxPanes(1), floating_panes_layout.clone());
swap_floating_layout_1.insert(LayoutConstraint::MinPanes(1), floating_panes_layout.clone());
swap_floating_layout_1.insert(
LayoutConstraint::ExactPanes(1),
floating_panes_layout.clone(),
);
swap_floating_layout_1.inser... |
rust_dataset_chunk_519751 | rust_dataset.txt | 519,751 | 512 | _styles_survive_a_layout_serialization_round_trip() {
use crate::data::LineStyle;
use crate::input::layout::Layout;
let border_style = BorderStyleOverride {
all: Some(LineStyle::Double),
top: Some(LineStyle::Heavy),
rounded_corners: Some(false),
..... |
rust_dataset_chunk_519752 | rust_dataset.txt | 519,752 | 512 | Layout::from_kdl(&kdl, Some("layout".to_owned()), None, None)
.unwrap_or_else(|e| panic!("failed to parse serialized layout: {:?}\n{}", e, kdl));
(kdl, layout)
}
#[test]
fn lone_pane_with_stale_stack_id_round_trips() {
let mut lone_geom = round_trip_geom(0, 0, Dimension::fix... |
rust_dataset_chunk_519753 | rust_dataset.txt | 519,753 | 512 | ],
..Default::default()
},
)],
..Default::default()
};
let (kdl, _layout) = serialize_and_parse(global_layout_manifest);
assert!(kdl.contains("stacked=true"), "{}", kdl);
assert!(kdl.contains("expanded=true")... |
rust_dataset_chunk_519754 | rust_dataset.txt | 519,754 | 512 | wd: Some(global_cwd.clone()),
tabs: vec![(
"tab".to_owned(),
TabLayoutManifest {
tiled_panes: vec![PaneLayoutManifest {
geom: round_trip_geom(0, 0, Dimension::fixed(10), Dimension::fixed(10)),
run: Some(Run::... |
rust_dataset_chunk_519755 | rust_dataset.txt | 519,755 | 512 | count(),
2,
"{}",
kdl
);
assert_eq!(stack.children.len(), 2, "{}", kdl);
assert!(stack.children.iter().all(|c| c.children.is_empty()));
}
#[test]
fn session_and_tab_attention_mute_survive_a_round_trip() {
let tab = |attention_muted: bool| ... |
rust_dataset_chunk_519756 | rust_dataset.txt | 519,756 | 512 | vec![
PaneLayoutManifest {
geom: round_trip_geom(0, 0, tiny_rows, Dimension::fixed(10)),
..Default::default()
},
PaneLayoutManifest {
geom: round_trip_geom(0, 1, b... |
rust_dataset_chunk_519757 | rust_dataset.txt | 519,757 | 512 | , stable
// session id rather than by the session's name, so renaming a session renames nothing on disk
// (Windows named pipes cannot be renamed). The session index maps names to ids. Sessions it
// doesn't know (started by versions from before ids) use their name as their id.
/// Generate a new session id: a short r... |
rust_dataset_chunk_519758 | rust_dataset.txt | 519,758 | 512 | session_id,
e
);
}
}
/// The id of the session with this name, if the session index knows it. Callers fall back to the
/// name itself, which is the id of sessions from before ids.
pub fn resolve_session_id(name: &str) -> Option<String> {
session_index::session_id_for_name(name)
}
/// The... |
rust_dataset_chunk_519759 | rust_dataset.txt | 519,759 | 512 | (current)
} else {
PaneSession::Ended(name.unwrap_or(current))
}
}
fn session_name(names_by_id: &HashMap<String, String>, id: String) -> String {
names_by_id.get(&id).cloned().unwrap_or(id)
}
pub fn get_sessions() -> Result<Vec<(String, Duration)>, io::ErrorKind> {
match fs::read_dir(&*ZELLIJ_... |
rust_dataset_chunk_519760 | rust_dataset.txt | 519,760 | 512 | , fall back to modification time on platforms where it's not supported (e.g., musl)
let ctime = std::fs::metadata(&layout_file_name)
.ok()
.and_then(|metadata| {
metadata.created().ok().or_else(|| metadata.modified().ok())
... |
rust_dataset_chunk_519761 | rust_dataset.txt | 519,761 | 512 | ) => {
log::error!(
"Failed to read session_info cache folder: \"{:?}\": {:?}",
&*ZELLIJ_SESSION_INFO_CACHE_DIR,
e
);
vec![]
},
}
}
pub fn get_sessions_sorted_by_mtime() -> anyhow::Result<Vec<String>> {
match fs::read_d... |
rust_dataset_chunk_519762 | rust_dataset.txt | 519,762 | 512 | (ClientToServerMsg::ConnStatus);
let mut receiver: IpcReceiverWithContext<ServerToClientMsg> = sender.get_receiver();
match receiver.recv_server_msg() {
Some((ServerToClientMsg::Connected, _)) => true,
None | Some((_, _)) => false,
}
},
... |
rust_dataset_chunk_519763 | rust_dataset.txt | 519,763 | 512 | 1.cmp(&b.1)
} else {
b.1.cmp(&a.1)
}
});
sessions
.iter()
.for_each(|(session_name, timestamp, is_dead)| {
if short {
println!("{}", session_name);
return;
}
if no_formatting {
let suf... |
rust_dataset_chunk_519764 | rust_dataset.txt | 519,764 | 512 | _session_socket_path(name).unwrap_or_else(|| ZELLIJ_SOCK_DIR.join(name));
if let Err(e) = send_kill_session(path) {
eprintln!("Error occurred: {:?}", e);
process::exit(1);
}
}
/// On Windows the server answers on the connection's reply pipe, and waiting for that answer
/// keeps the request fro... |
rust_dataset_chunk_519765 | rust_dataset.txt | 519,765 | 512 | .", name);
process::exit(2);
} else {
log::error!("Failed to remove session {:?}: {:?}", name, e);
}
} else {
println!("Session: {:?} successfully deleted.", name);
}
}
pub fn list_sessions(no_formatting: bool, short: bool, reverse: bool) {
let exit_code = ma... |
rust_dataset_chunk_519766 | rust_dataset.txt | 519,766 | 512 | , io::ErrorKind> {
match match_session_name(name) {
Ok(SessionNameMatch::Exact(_)) => Ok(true),
Ok(_) => Ok(false),
Err(e) => Err(e),
}
}
// if the session is resurrecable, the returned layout is the one to be used to resurrect it
pub fn resurrection_layout(session_name_to_resurrect: &s... |
rust_dataset_chunk_519767 | rust_dataset.txt | 519,767 | 512 | )
} else if exists && force {
println!("A session by the name {:?} exists and is active, but will be force killed and deleted.", name);
return;
} else {
return;
}
},
Err(e) => {
eprintln!("Error occurred: {:... |
rust_dataset_chunk_519768 | rust_dataset.txt | 519,768 | 512 | matches!(stem.as_str(), "CON" | "PRN" | "AUX" | "NUL") || numbered_device {
return Some(format!(
"Session name cannot be {:?}: Windows reserves that name.",
name
));
}
None
}
pub fn validate_session_folder_name(name: &str) -> Result<(), String> {
let mut components ... |
rust_dataset_chunk_519769 | rust_dataset.txt | 519,769 | 512 | : &str,
sock_dir: &Path,
session_info_cache_dir: &Path,
) -> BTreeMap<String, SessionInfo> {
let mut other_session_names: Vec<(String, Duration)> = vec![];
let mut session_infos_on_machine = BTreeMap::new();
if let Ok(files) = fs::read_dir(sock_dir) {
files.for_each(|file| {
if l... |
rust_dataset_chunk_519770 | rust_dataset.txt | 519,770 | 512 | let sessions = match sessions {
Ok(sessions) => sessions,
Err(kind) => {
eprintln!("{}", session_listing_error_message(kind));
return None;
},
};
let name = get_name_generator()
.take(1000)
.find(|name| !sessions.contains(name) && !dead_sessio... |
rust_dataset_chunk_519771 | rust_dataset.txt | 519,771 | 512 | ellifluous",
"nautical",
"oblong",
"outstanding",
"polished",
"polite",
"profound",
"quadratic",
"quiet",
"rectangular",
"remarkable",
"rusty",
"sensible",
"sincere",
"sparkling",
"splendid",
"stellar",
"tenacious",
"tremendous",
"triangular",
... |
rust_dataset_chunk_519772 | rust_dataset.txt | 519,772 | 512 | use super::*;
#[test]
fn generated_id_is_short_hex() {
let id = generate_session_id();
assert_eq!(id.len(), crate::consts::SESSION_ID_LENGTH);
assert!(
id.bytes().all(|b| b.is_ascii_hexdigit()),
"id should be hex: {}",
id
);
assert_ne... |
rust_dataset_chunk_519773 | rust_dataset.txt | 519,773 | 512 | to_owned())
);
}
#[test]
fn a_pane_of_an_ended_session_is_not_sent_to_whichever_session_runs() {
let names = index(&[("b2", "work")]);
assert_eq!(
resolve(Some("a1"), "work", &names, &["work"]),
PaneSession::Ended("work".to_owned())
);
let nam... |
rust_dataset_chunk_519774 | rust_dataset.txt | 519,774 | 512 | cfg(windows)]
#[test]
fn validate_session_name_rejects_backslash_on_windows() {
assert!(validate_session_name("a\\b").is_err());
}
#[cfg(windows)]
#[test]
fn validate_session_name_rejects_what_windows_cannot_name_a_file() {
for name in [
"a:b",
"a*",
... |
rust_dataset_chunk_519775 | rust_dataset.txt | 519,775 | 512 | ;
match Themes::from_string(&content.to_string(), sourced_from_external_file) {
Ok(theme) => themes = themes.merge(theme),
Err(_) => {},
}
}
}
themes
}
#[cfg(test)]
pub fn get_default_themes() -> Themes {
Themes::default()
}
pub fn dump_asset... |
rust_dataset_chunk_519776 | rust_dataset.txt | 519,776 | 512 | !("CARGO_MANIFEST_DIR"),
"/",
"assets/layouts/welcome.kdl"
));
pub const FISH_EXTRA_COMPLETION: &[u8] = include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/",
"assets/completions/comp.fish"
));
pub const BASH_EXTRA_COMPLETION: &[u8] = include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"... |
rust_dataset_chunk_519777 | rust_dataset.txt | 519,777 | 512 | (|h| h.join(&custom));
let layout_exists = path.as_ref().map(|p| p.exists()).unwrap_or_default();
match (path, layout_exists) {
(Some(path), true) => {
let content = fs::read_to_string(path)?;
std::io::stdout().write_all(content.as_bytes()... |
rust_dataset_chunk_519778 | rust_dataset.txt | 519,778 | 512 | ) in crate::distribution::embedded_plugins() {
let asset_path = PathBuf::from("plugins").join(format!("{}.wasm", name));
let plugin_path = path.join(&asset_path);
plugin_path
.parent()
.with_context(|| {
format!(
"failed to acquire pare... |
rust_dataset_chunk_519779 | rust_dataset.txt | 519,779 | 512 | HELL", value_parser)]
pub generate_completion: Option<String>,
/// Generates auto-start script for the specified shell
#[clap(long, value_name = "SHELL", value_parser)]
pub generate_auto_start: Option<String>,
/// Install the desktop entry, as the setup screen does: a launcher and icons on Linux, ... |
rust_dataset_chunk_519780 | rust_dataset.txt | 519,780 | 512 | install_desktop_entry: self.install_desktop_entry,
uninstall_desktop_entry: self.uninstall_desktop_entry,
make_default_terminal: self.make_default_terminal,
}
}
pub fn runs_setup_actions(&self) -> bool {
let actions = self.desktop_actions();
actions !=... |
rust_dataset_chunk_519781 | rust_dataset.txt | 519,781 | 512 | config_options =
apply_themes_to_config(&mut config, cli_config_options.clone(), cli_args)?;
let config_options_without_layout = apply_themes_to_config(
&mut config_without_layout,
cli_config_options.clone(),
cli_args,
)?;
if let Some(cli_config_o... |
rust_dataset_chunk_519782 | rust_dataset.txt | 519,782 | 512 | (0);
}
if let Some(swap_layout) = &self.dump_swap_layout {
dump_specified_swap_layout(swap_layout)?;
std::process::exit(0);
}
if let Some(keybinds) = &self.dump_keybinds {
dump_specified_keybinds(keybinds)?;
std::process::exit(0);
... |
rust_dataset_chunk_519783 | rust_dataset.txt | 519,783 | 512 | u{1b}]8;;";
let hyperlink_mid = "\u{1b}\\";
let hyperlink_end = "\u{1b}]8;;\u{1b}\\";
let mut message = String::new();
writeln!(&mut message, "[Version]: {:?}", VERSION).unwrap();
let distribution = crate::distribution::distribution();
if !distribution.is_stock_zellij()... |
rust_dataset_chunk_519784 | rust_dataset.txt | 519,784 | 512 | (&config_file, None) {
Ok(_) => message.push_str("[CONFIG FILE]: Well defined.\n"),
Err(e) => writeln!(
&mut message,
"[CONFIG ERROR]: {}. \n By default, zellij loads default configuration",
e
)
.... |
rust_dataset_chunk_519785 | rust_dataset.txt | 519,785 | 512 | ROW SEPARATOR]: {}", ARROW_SEPARATOR).unwrap();
message.push_str(" Is the [ARROW_SEPARATOR] displayed correctly?\n");
message.push_str(" If not you may want to either start zellij with a compatible mode: 'zellij options --simplified-ui true'\n");
let mut hyperlink_compat = String::new();
... |
rust_dataset_chunk_519786 | rust_dataset.txt | 519,786 | 512 | exit(1);
},
};
let mut out = std::io::stdout();
clap_complete::generate(
shell,
&mut CliArgs::command_for_distribution(),
crate::distribution::name(),
&mut out,
);
// add shell dependent extra completion
match sh... |
rust_dataset_chunk_519787 | rust_dataset.txt | 519,787 | 512 | up and all the decisions should happen here
let (layout_info, chosen_layout) = if let Some(ref layout_string) = cli_args.layout_string {
(Some(LayoutInfo::Stringified(layout_string.clone())), None)
} else if let Some(chosen_layout) = cli_args.layout.clone() {
let layout_info = L... |
rust_dataset_chunk_519788 | rust_dataset.txt | 519,788 | 512 | None => Some(options.to_owned().into()),
},
_ => cli_config_options,
}
}
#[cfg(test)]
mod setup_test {
use super::Setup;
use crate::cli::{CliArgs, Command};
use crate::data::LayoutInfo;
use crate::input::options::Options;
use insta::assert_snapshot;
use std::path... |
rust_dataset_chunk_519789 | rust_dataset.txt | 519,789 | 512 | layout_info, options, _, _) = Setup::from_cli_args(&cli_args).unwrap();
assert_snapshot!(format!("{:#?}", options));
let Some(LayoutInfo::File(layout_path, _)) = layout_info else {
panic!("layout info doesn't have expected format");
};
assert_eq!(
layout_path,
... |
rust_dataset_chunk_519790 | rust_dataset.txt | 519,790 | 512 | _args).unwrap();
assert_snapshot!(format!("{:#?}", config));
}
#[test]
fn layout_keybinds_override_config_keybinds() {
let mut cli_args = CliArgs::default();
cli_args.config = Some(PathBuf::from(format!(
"{}/src/test-fixtures/config-with-keybindings-config.kdl",
... |
rust_dataset_chunk_519791 | rust_dataset.txt | 519,791 | 512 | ();
assert_eq!(layout_path, expected.display().to_string());
}
#[test]
fn cli_with_relative_layout_and_extension() {
// NOTE: We assume to be in `zellij-utils` root directory. If this doesn't hold, path
// resolution cannot work (as it actually reads path to ensure they exist).
... |
rust_dataset_chunk_519792 | rust_dataset.txt | 519,792 | 512 | layout info should be Stringified variant, got: {:#?}",
layout_info
);
};
assert_eq!(content, layout_kdl);
}
}
--- FILE: zellij/zellij-utils/src/shared.rs ---
//! Some general utility functions.
use std::net::{IpAddr, Ipv4Addr};
use std::{iter, str::from_utf8};
use cr... |
rust_dataset_chunk_519793 | rust_dataset.txt | 519,793 | 512 | take(rows)
.collect::<Vec<_>>()
.join("\n\r")
}
fn escape_sequence_len(s: &str) -> usize {
let bytes = s.as_bytes();
if bytes.len() < 2 {
return bytes.len();
}
match bytes[1] {
b'[' => {
let mut i = 2;
while i < bytes.len() {
if (0... |
rust_dataset_chunk_519794 | rust_dataset.txt | 519,794 | 512 | rest[len..];
}
break;
}
}
out
}
pub fn make_terminal_title(pane_title: &str) -> String {
let pane_title = crate::graphemes::strip_control_characters(pane_title);
format!(
"\u{1b}]0;{}{}\u{07}",
get_session_name()
.map(|n| {
let... |
rust_dataset_chunk_519795 | rust_dataset.txt | 519,795 | 512 | , u8) = (137, 137, 137);
pub const DIM: (u8, u8, u8) = (105, 105, 105);
pub const GREEN: (u8, u8, u8) = (150, 220, 90);
pub const GOLD: (u8, u8, u8) = (255, 205, 80);
pub const BLUE: (u8, u8, u8) = (70, 175, 255);
pub const ROSE: (u8, u8, u8) = (255, 95, 110);
pub const VIOLET: (u8, u8, u8) = (2... |
rust_dataset_chunk_519796 | rust_dataset.txt | 519,796 | 512 | ThemeHue::Dark,
fg: PaletteColor::Rgb(default_theme_colors::FOREGROUND),
bg: PaletteColor::Rgb(default_theme_colors::BACKGROUND),
black: PaletteColor::Rgb(default_theme_colors::BACKGROUND),
red: PaletteColor::Rgb(default_theme_colors::ROSE),
green: PaletteColor::Rgb(default_them... |
rust_dataset_chunk_519797 | rust_dataset.txt | 519,797 | 512 | version.split('.');
for (i, semver_version) in semver_versions.rev().enumerate() {
let semver_number = semver_version.parse::<usize>().unwrap_or(0);
version_number += usize::pow(100, i as u32) * semver_number;
}
version_number
}
pub fn web_server_base_url(
web_server_ip: IpAddr,
w... |
rust_dataset_chunk_519798 | rust_dataset.txt | 519,798 | 512 | URL"))?
.to_string();
let port = url
.port_or_known_default()
.ok_or_else(|| anyhow!("No port in URL"))?;
Ok(ServerAddress { ip, port })
}
#[cfg(test)]
mod web_server_base_url_tests {
use super::*;
fn remote() -> IpAddr {
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))
}
... |
rust_dataset_chunk_519799 | rust_dataset.txt | 519,799 | 512 | (options),
"http://0.0.0.0:8082"
);
let options = Options {
web_server_ip: Some(remote()),
..Default::default()
};
assert_eq!(
web_server_base_url_from_config(options),
"https://0.0.0.0:8082"
);
}
}
#[cfg(test)]
mod... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.