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_511600 | rust_dataset.txt | 511,600 | 512 | fn get_terminal_size_fallback_values() {
// Verify the fallback constants are what we expect
let fallback = Size { rows: 24, cols: 80 };
// When crossterm::terminal::size() fails (no terminal), we should get 80x24
// This is implicitly tested by get_terminal_size_returns_nonzero_or_f... |
rust_dataset_chunk_511601 | rust_dataset.txt | 511,601 | 512 | signal(SignalKind::interrupt())?,
sigquit: signal(SignalKind::quit())?,
sighup: signal(SignalKind::hangup())?,
})
}
}
#[async_trait]
impl crate::os_input_output::AsyncSignals for AsyncSignalListener {
async fn recv(&mut self) -> Option<SignalEvent> {
tokio::select! {
... |
rust_dataset_chunk_511602 | rust_dataset.txt | 511,602 | 512 | consts::ipc_connect(path) {
Ok(socket) => break socket,
Err(e) => {
if let Some(limit) = give_up_after {
if e.kind() == io::ErrorKind::NotFound || started.elapsed() >= limit {
return Err(e);
}
}
... |
rust_dataset_chunk_511603 | rust_dataset.txt | 511,603 | 512 | a stale socket");
assert_ne!(error.kind(), io::ErrorKind::NotFound);
assert!(started.elapsed() >= limit);
assert!(started.elapsed() < Duration::from_secs(5));
assert!(crate::connect_error_message(error).starts_with("Error: cannot connect"));
}
#[test]
fn a_server_that_is_li... |
rust_dataset_chunk_511604 | rust_dataset.txt | 511,604 | 512 | stdin path had
/// just set and broke all input from WT.
pub(crate) fn use_vt_path() -> bool {
std::env::var("TERM").is_ok() || std::env::var("WT_SESSION").is_ok()
}
/// Windows async signal listener.
///
/// Polls `crossterm::terminal::size()` at 100ms intervals for resize events,
/// and listens to `tokio::sign... |
rust_dataset_chunk_511605 | rust_dataset.txt | 511,605 | 512 | **: receives resize notifications forwarded from the stdin
/// thread (which gets `Event::Resize` from crossterm). Much more responsive
/// than polling.
/// - **Poll fallback**: polls `crossterm::terminal::size()` at 50ms intervals.
/// Used when no receiver is provided or when the sender is dropped (VT reader
/... |
rust_dataset_chunk_511606 | rust_dataset.txt | 511,606 | 512 | let Some(ref rx) = self.resize_receiver {
// Channel mode: the native console stdin loop sends resize
// notifications through this channel. Block with a timeout so
// we can periodically check the quit flag above.
match rx.recv_timeout(Duration::from_mil... |
rust_dataset_chunk_511607 | rust_dataset.txt | 511,607 | 512 | thread::sleep(std::time::Duration::from_millis(50))
},
}
};
let sender = IpcSenderWithContext::new(socket);
let receiver = IpcReceiverWithContext::new(reply_socket);
Ok((sender, receiver))
}
/// Enable ENABLE_VIRTUAL_TERMINAL_PROCESSING on stdout so that ConPTY enters
/// passthroug... |
rust_dataset_chunk_511608 | rust_dataset.txt | 511,608 | 512 | restore_console_mode() {
restore_vt_input();
}
/// Disable mouse support on Windows.
///
/// See `enable_mouse_support()` for rationale on VT vs Console API paths.
pub(crate) fn disable_mouse_support(stdout: &mut dyn Write) -> Result<()> {
let err_context = "failed to disable mouse mode";
if use_vt_path()... |
rust_dataset_chunk_511609 | rust_dataset.txt | 511,609 | 512 | ("User-Agent", "http-terminal-client/1.0")
.header("Accept", "application/json")
.body(
serde_json::to_vec(&login_request)
.map_err(|e| RemoteClientError::Other(Box::new(e)))?,
)
.map_err(|e| RemoteClientError::O... |
rust_dataset_chunk_511610 | rust_dataset.txt | 511,610 | 512 | ))
}
pub async fn validate_session_token(
server_base_url: &str,
session_token: &str,
session_name: &str,
ca_cert: Option<&std::path::Path>,
insecure: bool,
) -> Result<(String, HttpClientWithCookies), RemoteClientError> {
let http_client = HttpClientWithCookies::new(ca_cert, insecure)
... |
rust_dataset_chunk_511611 | rust_dataset.txt | 511,611 | 512 | Duration::from_secs(CONNECTION_TIMEOUT_SECS)
}
--- FILE: zellij/zellij-client/src/remote_attach/http_client.rs ---
use super::config::connection_timeout;
use isahc::prelude::*;
use isahc::{config::RedirectPolicy, AsyncBody, HttpClient, Request, Response};
use std::collections::HashMap;
use std::path::Path;
use std::... |
rust_dataset_chunk_511612 | rust_dataset.txt | 511,612 | 512 | _cookie_headers) = response.headers().get_all("set-cookie").iter().next() {
if let Ok(cookie_str) = set_cookie_headers.to_str() {
self.parse_and_store_cookies(cookie_str);
}
}
Ok(response)
}
fn parse_and_store_cookies(&self, cookie_header: &str) {
... |
rust_dataset_chunk_511613 | rust_dataset.txt | 511,613 | 512 | _session_tokens;
// In tests, only attempt once (no retries) to avoid interactive prompts
// In production, allow up to 3 attempts (initial + 2 retries)
#[cfg(test)]
const MAX_AUTH_ATTEMPTS: u32 = 1;
#[cfg(not(test))]
const MAX_AUTH_ATTEMPTS: u32 = 3;
/// Attach to a remote Zellij session via HTTP(S)
///
/// This fu... |
rust_dataset_chunk_511614 | rust_dataset.txt | 511,614 | 512 | _session_token)) = remote_session_tokens::get_session_token(server_url) {
// we have a saved session token, let's try to authenticate with it
let ca_cert_owned = ca_cert.map(|p| p.to_path_buf());
match runtime.block_on(async move {
remote_attach_with_session_token(
re... |
rust_dataset_chunk_511615 | rust_dataset.txt | 511,615 | 512 | we got one
if let Some(session_token) = session_token_opt {
let server_url = extract_server_url(remote_session_url)?;
let _ = remote_session_tokens::save_session_token(&server_url, &session_token);
}
return Ok(connections);
... |
rust_dataset_chunk_511616 | rust_dataset.txt | 511,616 | 512 | ,
) -> Result<websockets::WebSocketConnections, RemoteClientError> {
let server_base_url = extract_server_url(server_url)?;
let session_name = extract_session_name(server_url)?;
let (web_client_id, http_client) = auth::validate_session_token(
&server_base_url,
session_token,
&session... |
rust_dataset_chunk_511617 | rust_dataset.txt | 511,617 | 512 | ::TcpListener;
use uuid::Uuid;
#[derive(Clone)]
pub struct MockRemoteServerState {
pub valid_auth_tokens: Arc<Mutex<HashMap<String, ()>>>,
pub session_tokens: Arc<Mutex<HashMap<String, String>>>, // token -> web_client_id
pub endpoints_called: Arc<Mutex<Vec<String>>>,
pub qu... |
rust_dataset_chunk_511618 | rust_dataset.txt | 511,618 | 512 | let web_client_id = Uuid::new_v4().to_string();
state
.session_tokens
.lock()
.unwrap()
.insert(session_token.clone(), web_client_id);
let cookie = Cookie::build(("session_token", session_token))
.path("/")
.http_only(true... |
rust_dataset_chunk_511619 | rust_dataset.txt | 511,619 | 512 | use axum::extract::ws::Message;
use futures_util::{SinkExt, StreamExt};
let (mut sender, mut receiver) = socket.split();
while let Some(Ok(msg)) = receiver.next().await {
if let Message::Text(text) = msg {
let _ = sender.send(Message::... |
rust_dataset_chunk_511620 | rust_dataset.txt | 511,620 | 512 | server to be ready
tokio::time::sleep(Duration::from_millis(100)).await;
(port, server_handle)
}
}
#[cfg(feature = "web_server_capability")]
mod tls_mock_server {
use super::mock_server::MockRemoteServerState;
use axum::routing::{get, post};
use axum::Router;
use axum_server::tls_... |
rust_dataset_chunk_511621 | rust_dataset.txt | 511,621 | 512 | std::fs::write(ca_cert_file.path(), ca.pem()).unwrap();
let server_cert_file = tempfile::NamedTempFile::new().unwrap();
std::fs::write(server_cert_file.path(), server_cert.pem()).unwrap();
let server_key_file = tempfile::NamedTempFile::new().unwrap();
std::fs::write(server_key_... |
rust_dataset_chunk_511622 | rust_dataset.txt | 511,622 | 512 | for the server to be listening (deterministic, no sleep)
handle.listening().await;
(port, handle, server_task)
}
pub async fn shutdown_server(
handle: Handle<SocketAddr>,
server_task: tokio::task::JoinHandle<()>,
) {
handle.graceful_shutdown(Some(Duration::from_sec... |
rust_dataset_chunk_511623 | rust_dataset.txt | 511,623 | 512 | _string()),
"Should call login endpoint"
);
assert!(
endpoints.contains(&"/session".to_string()),
"Should call session endpoint"
);
assert!(
endpoints.contains(&"/ws/terminal".to_string()),
"Should establish terminal WebSocket"
... |
rust_dataset_chunk_511624 | rust_dataset.txt | 511,624 | 512 | #[tokio::test]
#[serial]
async fn test_save_session_token_with_remember_true() {
let server_state = MockRemoteServerState::new();
let auth_token = "test-token-remember";
server_state.add_valid_token(auth_token);
let (port, server_handle) = start_mock_server(server_state.clone()... |
rust_dataset_chunk_511625 | rust_dataset.txt | 511,625 | 512 | server_state = MockRemoteServerState::new();
// Pre-create a session token
let session_token = uuid::Uuid::new_v4().to_string();
let web_client_id = uuid::Uuid::new_v4().to_string();
server_state
.session_tokens
.lock()
.unwrap()
.insert(... |
rust_dataset_chunk_511626 | rust_dataset.txt | 511,626 | 512 | The old token should have been deleted before using new one
// (New token won't be saved because remember=false)
// Verify by checking that session endpoint was called (not using saved token)
let endpoints = server_state.get_endpoints_called();
assert!(
endpoints.contains(&"... |
rust_dataset_chunk_511627 | rust_dataset.txt | 511,627 | 512 | Wrong session name for URL: {}",
url
);
}
}
#[tokio::test]
async fn test_server_url_extraction() {
// Test various URL formats
let test_cases = vec![
(
"https://example.com:8080/session?foo=bar",
"https://exampl... |
rust_dataset_chunk_511628 | rust_dataset.txt | 511,628 | 512 | -> (
String,
crate::remote_attach::http_client::HttpClientWithCookies,
) {
let session_token = uuid::Uuid::new_v4().to_string();
let web_client_id = uuid::Uuid::new_v4().to_string();
server_state
.session_tokens
.lock()
.unwrap()
... |
rust_dataset_chunk_511629 | rust_dataset.txt | 511,629 | 512 | crate::remote_attach::websockets;
let certs = tls_mock_server::generate_test_certs();
let server_state = MockRemoteServerState::new();
let (port, handle, server_task) =
tls_mock_server::start_tls_mock_server(server_state.clone(), &certs).await;
let (web_client_id, http_cl... |
rust_dataset_chunk_511630 | rust_dataset.txt | 511,630 | 512 | )
.await
.expect("Test timed out");
assert!(
result.is_err(),
"TLS without CA cert should reject self-signed server"
);
tls_mock_server::shutdown_server(handle, server_task).await;
}
}
// Tests that don't require the web_server_capability feature
#... |
rust_dataset_chunk_511631 | rust_dataset.txt | 511,631 | 512 | MaybeTls::Plain(s) => Pin::new(s).poll_write(cx, buf),
MaybeTls::Tls(s) => Pin::new(s).poll_write(cx, buf),
}
}
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
match self.get_mut() {
MaybeTls::Plain(s) => Pin::new(s).poll_flush(c... |
rust_dataset_chunk_511632 | rust_dataset.txt | 511,632 | 512 | client::danger::HandshakeSignatureValid, rustls::Error> {
Ok(rustls::client::danger::HandshakeSignatureValid::assertion())
}
fn supported_verify_schemes(&self) -> Vec<rustls::SignatureScheme> {
rustls::crypto::aws_lc_rs::default_provider()
.signature_verification_algorithms
... |
rust_dataset_chunk_511633 | rust_dataset.txt | 511,633 | 512 | fn connect_ws(
request: tokio_tungstenite::tungstenite::http::Request<()>,
host: &str,
port: u16,
tls_config: Option<Arc<rustls::ClientConfig>>,
) -> Result<WebSocketStream<MaybeTls>, Box<dyn std::error::Error>> {
let tcp_stream = TcpStream::connect((host, port)).await?;
let stream = if let So... |
rust_dataset_chunk_511634 | rust_dataset.txt | 511,634 | 512 | http_client: &HttpClientWithCookies,
server_base_url: &str,
session_name: &str,
ca_cert: Option<&Path>,
insecure: bool,
declaration: ClientDeclaration,
) -> Result<WebSocketConnections, Box<dyn std::error::Error>> {
let parsed_url = url::Url::parse(server_base_url)?;
let host = parsed_url
... |
rust_dataset_chunk_511635 | rust_dataset.txt | 511,635 | 512 | &base_host)
.header("Upgrade", "websocket")
.header("Connection", "Upgrade")
.header(
"Sec-WebSocket-Key",
tokio_tungstenite::tungstenite::handshake::client::generate_key(),
)
.header("Sec-WebSocket-Version", "13");
// Add cookies if available
if... |
rust_dataset_chunk_511636 | rust_dataset.txt | 511,636 | 512 | env::current_exe;
use std::ffi::OsString;
use std::io;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LaunchStyle {
WaitForDaemon,
Detached,
}
pub const fn launch_style(windows: bool) -> LaunchStyle {
if windows {
LaunchSty... |
rust_dataset_chunk_511637 | rust_dataset.txt | 511,637 | 512 | let mut cmd = launch.command();
match launch_style(cfg!(windows)) {
LaunchStyle::WaitForDaemon => {
let status = cmd.status()?;
if status.success() {
Ok(())
} else {
let msg = "Process returned non-zero exit code";
let e... |
rust_dataset_chunk_511638 | rust_dataset.txt | 511,638 | 512 | (windows)]
impl Drop for WithheldStdio {
fn drop(&mut self) {
use windows_sys::Win32::Foundation::{SetHandleInformation, HANDLE_FLAG_INHERIT};
for handle in &self.0 {
unsafe { SetHandleInformation(*handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT) };
}
}
}
#[cfg(test)]
mod t... |
rust_dataset_chunk_511639 | rust_dataset.txt | 511,639 | 512 | let launch = ServerLaunch::new(OsString::from("false"), Path::new("/sock"));
assert!(spawn_server_with(&launch).is_err());
}
}
--- FILE: zellij/zellij-client/src/session_resolution.rs ---
use std::path::PathBuf;
use std::time::Duration;
use zellij_utils::cli::{AttachArgs, SessionCommand};
use zellij_uti... |
rust_dataset_chunk_511640 | rust_dataset.txt | 511,640 | 512 | ,
}
}
fn to_stdout(message: impl Into<String>, exit_code: i32) -> Self {
ResolutionFailure {
message: message.into(),
stream: Stream::Out,
exit_code,
listing: None,
}
}
fn listing(mut self, listing: SessionListing) -> Self {
... |
rust_dataset_chunk_511641 | rust_dataset.txt | 511,641 | 512 | {
if create {
create_new_client()
} else {
Err(ResolutionFailure::to_stderr(
"No active zellij sessions found.",
1,
))
}
},
Ok(sessions) => find_indexed_session(sessions, config_o... |
rust_dataset_chunk_511642 | rust_dataset.txt | 511,642 | 512 | }
}
pub fn resolve_attach(
args: &AttachArgs,
config_options: Options,
create_detached: bool,
new_session_cwd: Option<PathBuf>,
) -> Result<Resolved, ResolutionFailure> {
let config_options = match args.options.as_deref() {
Some(SessionCommand::Options(o)) => config_options.merge_from_cli(... |
rust_dataset_chunk_511643 | rust_dataset.txt | 511,643 | 512 | config_options))
},
Ok(SessionNameMatch::AmbiguousPrefix(sessions)) => Err(ResolutionFailure::to_stderr(
format!(
"Ambiguous selection: multiple sessions names start with '{}':",
prefix
),
1,
)
... |
rust_dataset_chunk_511644 | rust_dataset.txt | 511,644 | 512 | let resolved = resolve_attach(&args, Options::default(), false, None).unwrap();
assert!(matches!(
resolved.client,
ClientInfo::New(ref name, ..) if name == "zellij-terminal-no-such-session"
));
}
#[test]
fn a_watcher_refuses_a_name_that_is_not_live() {
asser... |
rust_dataset_chunk_511645 | rust_dataset.txt | 511,645 | 512 | {
SyncOutput::DCS => DCS_ESU_SEQ,
SyncOutput::CSI => CSI_ESU_SEQ,
}
}
}
/// A classified host-terminal reply received on stdin.
///
/// The variants track the reply types Zellij consumes for its own
/// synchronous render hot-path (pixel dims, bg/fg, palette registers,
/// sync-out... |
rust_dataset_chunk_511646 | rust_dataset.txt | 511,646 | 512 | new(r"^4;(\d+);(.*)$").unwrap();
}
let s = std::str::from_utf8(payload).ok()?;
if s == "7501;?" || s.starts_with("7501;?:") {
return Some(HostReply::ProgramStatusSupport);
}
if let Some(caps) = BG_RE.captures(s) {
return Some(HostReply::BackgroundColor(cap... |
rust_dataset_chunk_511647 | rust_dataset.txt | 511,647 | 512 | = Regex::new(r"^\u{1b}\[\?997;([12])n$").unwrap();
static ref GRAPHEME_CLUSTER_RE: Regex = Regex::new(r"^\u{1b}\[\?2027;([0-4])\$y$").unwrap();
}
if let Some(caps) = GRAPHEME_CLUSTER_RE.captures(s) {
let value: u8 = caps[1].parse().ok()?;
return Some(HostReply::Graph... |
rust_dataset_chunk_511648 | rust_dataset.txt | 511,648 | 512 | they do not clobber the host capability state.
pub fn sixel_support_from_primary_da(raw: &[u8]) -> Option<HostReply> {
lazy_static! {
static ref PRIMARY_DA_RE: Regex = Regex::new(r"^\u{1b}\[\?([0-9;]*)c$").unwrap();
}
let s = std::str::from_utf8(raw).ok()?;
let caps = PR... |
rust_dataset_chunk_511649 | rust_dataset.txt | 511,649 | 512 | >,
pub completed_clipboard_forward: Option<(u32, Vec<u8>)>,
/// OSC 99 notification-response payloads (one per OSC 99 found in
/// the chunk). Routed by the caller as
/// `InputInstruction::DesktopNotificationResponse`. Lives here, not
/// in the keyboard-parser path, because the residue scrubber
... |
rust_dataset_chunk_511650 | rust_dataset.txt | 511,650 | 512 | ,
ReplyInProgress,
}
impl PendingPartial {
pub fn uses_reply_flush_guard(&self) -> bool {
matches!(self, PendingPartial::ReplyInProgress)
}
}
#[derive(Debug, Clone, Copy)]
enum MarkerMatch {
Complete,
Prefix,
No,
}
fn marker_match(buf: &[u8], marker: &[u8]) -> MarkerMatch {
if buf... |
rust_dataset_chunk_511651 | rust_dataset.txt | 511,651 | 512 | KittyProbe,
partial_apc: Vec<u8>,
primary_da_answered: bool,
exit_draining: bool,
}
impl std::fmt::Debug for StdinAnsiParser {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("StdinAnsiParser")
.field("batches", &self.batches)
.field("... |
rust_dataset_chunk_511652 | rust_dataset.txt | 511,652 | 512 | hand a still-open slot over with `take_active_forward`
/// first. The guards below catch a caller that skipped that handover:
/// debug builds panic so bugs surface during testing, release builds
/// log and clobber the previous slot (whose accumulated bytes would
/// otherwise silently leak).
pub ... |
rust_dataset_chunk_511653 | rust_dataset.txt | 511,653 | 512 | _BATCH_EXPIRY);
}
fn live_forward(&self) -> Option<&ForwardSlot> {
self.batches.iter().find_map(|batch| match &batch.owner {
BatchOwner::Pane(slot) if !slot.abandoned => Some(slot),
_ => None,
})
}
fn live_forward_mut(&mut self) -> Option<&mut ForwardSlot> {
... |
rust_dataset_chunk_511654 | rust_dataset.txt | 511,654 | 512 | pub fn close_clipboard_forward_on_timeout(&mut self, token: u32) -> Option<(u32, Vec<u8>)> {
match &self.active_clipboard_forward {
Some(slot) if slot.token == token => {
let slot = self.active_clipboard_forward.take().unwrap();
Some((slot.token, Vec::new()))
... |
rust_dataset_chunk_511655 | rust_dataset.txt | 511,655 | 512 | {
// OSC 99 (desktop-notification response) is routed
// here rather than from the keyboard parser because
// the residue scrubber removes all OSC bytes before
// the keyboard parser runs. Other OSCs are
// classified i... |
rust_dataset_chunk_511656 | rust_dataset.txt | 511,656 | 512 | && self.startup_grapheme_cluster_probe
== StartupKittyProbe::AwaitingReply
{
self.startup_grapheme_cluster_probe = StartupKittyProbe::Resolved;
out.replies.push(HostReply::GraphemeClusterMode... |
rust_dataset_chunk_511657 | rust_dataset.txt | 511,657 | 512 | can the
// buffer a second time below.
other => {
if self.active_clipboard_forward.is_some()
&& is_user_input(&other)
&& out.completed_clipboard_forward.is_none()
{
if let Some... |
rust_dataset_chunk_511658 | rust_dataset.txt | 511,658 | 512 | _empty() && self.partial_csi == [0x1b, b'['] {
PendingPartial::BareIntroducer
} else {
PendingPartial::ReplyInProgress
}
}
pub fn finalize_fast_partial(&mut self) -> Vec<u8> {
let drained = self.take_fast_partial();
if !drained.is_empty() {
se... |
rust_dataset_chunk_511659 | rust_dataset.txt | 511,659 | 512 | () {
let rest = &working[i..];
if rest.len() >= 2 && rest[0] == 0x1b && rest[1] == b'_' {
match rest.get(2) {
Some(&b'G') => {},
Some(_) => {
out.push(working[i]);
i += 1;
... |
rust_dataset_chunk_511660 | rust_dataset.txt | 511,660 | 512 | , the unterminated tail is held in
/// `self.partial_osc` or `self.partial_csi` and prepended to the
/// next call's input — so the corresponding bytes never reach
/// residue (and never appear as spurious keypresses) while waiting
/// for the rest of the sequence.
fn strip_replies(&mut self, bytes:... |
rust_dataset_chunk_511661 | rust_dataset.txt | 511,661 | 512 | ESC ] ... (BEL | ESC \)
if rest.len() >= 2 && rest[0] == 0x1b && rest[1] == b']' {
match osc_status(rest) {
SeqStatus::Complete(len) => {
i += len;
continue;
},
SeqStatus::NeedMore =>... |
rust_dataset_chunk_511662 | rust_dataset.txt | 511,662 | 512 | if buf.get(0) != Some(&0x1b) || buf.get(1) != Some(&b']') {
return SeqStatus::Malformed;
}
let mut i = 2;
while i < buf.len() {
match buf[i] {
0x07 => return SeqStatus::Complete(i + 1),
0x1b => match buf.get(i + 1) {
Some(&b'\\') => return SeqStatus::... |
rust_dataset_chunk_511663 | rust_dataset.txt | 511,663 | 512 | x2F => i += 1,
b't' | b'y' | b'c' | b'n' => return SeqStatus::Complete(i + 1),
0x40..=0x7E => return SeqStatus::Malformed, // non-whitelisted final
_ => return SeqStatus::Malformed,
}
}
if i >= max {
// CSI ran past the cap without terminating — treat as malfo... |
rust_dataset_chunk_511664 | rust_dataset.txt | 511,664 | 512 | forward) has already cleared the slot by the time the
/// timer wakes, `close_forward_on_timeout(token)` returns `None` and
/// `on_timeout` is never called — no explicit cancellation path
/// required.
///
/// Extracted as a free function so tests can drive it against a
/// `tokio::time::pause()`-backed paused runtim... |
rust_dataset_chunk_511665 | rust_dataset.txt | 511,665 | 512 | () {
// CSI 4 ; H ; W t
let mut parser = StdinAnsiParser::new();
let (replies, residue) = feed_once(&mut parser, b"\x1b[4;720;1280t");
assert!(
residue.is_empty(),
"pixel-dim reply should be fully consumed"
);
assert_eq!(replies.len(), 1);
match &replies[0] {
HostRepl... |
rust_dataset_chunk_511666 | rust_dataset.txt | 511,666 | 512 | => panic!("unexpected reply: {:?}", other),
}
}
#[test]
fn color_register_reply() {
let mut parser = StdinAnsiParser::new();
let (replies, residue) = feed_once(&mut parser, b"\x1b]4;5;rgb:8080/8080/8080\x1b\\");
assert!(residue.is_empty());
match &replies[0] {
HostReply::ColorRegisters(reg... |
rust_dataset_chunk_511667 | rust_dataset.txt | 511,667 | 512 | ::PixelDimensions(_));
assert_eq!(residue, b"\x1b[A\x1b[B");
}
#[test]
fn unterminated_osc_within_single_chunk_is_buffered() {
// An OSC that never terminates within a chunk is held in the
// partial-OSC buffer for the next call to complete; nothing leaks
// into residue. This is the cross-chunk-aware ... |
rust_dataset_chunk_511668 | rust_dataset.txt | 511,668 | 512 | !reply_bytes.contains(&b'c'),
"Primary-DA barrier (final byte 'c') must not appear in forwarded reply"
);
// Slot released.
assert!(parser.active_forward_token().is_none());
}
#[test]
fn unsolicited_osc_between_forwarded_query_and_barrier() {
// Scenario: host emits a stray OSC 10 betwe... |
rust_dataset_chunk_511669 | rust_dataset.txt | 511,669 | 512 | (token, bytes) = flushed.expect("timeout flush should produce a payload");
assert_eq!(token, 99);
assert!(bytes.windows(4).any(|w| w == b"]11;"));
assert!(parser.active_forward_token().is_none());
}
#[test]
fn stale_token_timeout_does_nothing() {
let mut parser = StdinAnsiParser::new();
parser.ope... |
rust_dataset_chunk_511670 | rust_dataset.txt | 511,670 | 512 | 2.replies.len(), 1);
}
}
#[test]
fn fragmented_osc_byte_by_byte() {
// Every byte in its own chunk — the worst case.
let full = b"\x1b]11;rgb:abcd/ef01/2345\x1b\\";
let mut p = StdinAnsiParser::new();
let mut total_replies = 0;
for &b in full {
let out = p.feed(&[b]);
assert!(ou... |
rust_dataset_chunk_511671 | rust_dataset.txt | 511,671 | 512 | enough the idle path is never taken, and
// the OSC completes normally. We exercise that order here.
let full = b"\x1b]11;rgb:0000/0000/0000\x1b\\";
let mut p = StdinAnsiParser::new();
let r1 = p.feed(&full[..1]);
assert!(r1.residue.is_empty());
assert!(r1.has_partial_state);
let r2 = p.fee... |
rust_dataset_chunk_511672 | rust_dataset.txt | 511,672 | 512 | 0], b"notification body".to_vec());
}
#[test]
fn osc_99_does_not_leak_into_an_open_forwarding_window() {
let mut parser = StdinAnsiParser::new();
parser.open_forward(7);
let mut chunk = Vec::new();
chunk.extend_from_slice(b"\x1b]99;i=p1.myid;\x1b\\");
chunk.extend_from_slice(b"\x1b]11;rgb:1111/1111... |
rust_dataset_chunk_511673 | rust_dataset.txt | 511,673 | 512 | inAnsiParser::new();
let _ = p.feed(b"\x1b]10;partial");
let _ = p.feed(b"\x1b\\");
let out = p.feed(b"hello");
assert_eq!(out.residue, b"hello");
}
#[test]
fn cross_chunk_osc_assembles_across_feeds() {
// An OSC 11 reply split across two `feed()` calls. The inner
// `InputParser` buffers OSC s... |
rust_dataset_chunk_511674 | rust_dataset.txt | 511,674 | 512 | b"\x1b]10;rgb:1111/2222/3333\x1b\\",
|r| matches!(r, HostReply::ForegroundColor(_)),
"OSC 10",
),
(
b"\x1b]4;9;rgb:4444/5555/6666\x1b\\",
|r| matches!(r, HostReply::ColorRegisters(_)),
"OSC 4",
),
(
b"\x1b[4;720;128... |
rust_dataset_chunk_511675 | rust_dataset.txt | 511,675 | 512 | // prefix (`\x1b[>0;276;0c`). Both must close the forward window
// the same way the bare `\x1b[c` does.
for barrier in [
b"\x1b[c".as_ref(),
b"\x1b[?62;1;6c".as_ref(),
b"\x1b[>0;276;0c".as_ref(),
] {
let mut parser = StdinAnsiParser::new();
parser.open_forward(5);
... |
rust_dataset_chunk_511676 | rust_dataset.txt | 511,676 | 512 | Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_time()
.start_paused(true)
.build()
.expect("paused runtime build must succeed")
}
#[test]
fn timer_fires_after_deadline_and_closes_slot() {
let rt = paused_runtime();
let parser = Arc::new(Mutex::new(StdinAnsiP... |
rust_dataset_chunk_511677 | rust_dataset.txt | 511,677 | 512 | reply
// and the Primary-DA barrier; the parser's `completed_forward`
// path clears the slot.
{
let mut p = parser.lock().unwrap();
let mut chunk = Vec::new();
chunk.extend_from_slice(b"\x1b]11;rgb:0/0/0\x1b\\");
chunk.extend_from_slice(b"\x1b[c");
let out = p.feed(... |
rust_dataset_chunk_511678 | rust_dataset.txt | 511,678 | 512 | ().await;
tokio::time::advance(Duration::from_millis(600)).await;
tokio::task::yield_now().await;
});
assert!(
!*fired.lock().unwrap(),
"stale timer must not close the new slot"
);
assert_eq!(
parser.lock().unwrap().active_forward_token(),
Some(2),
... |
rust_dataset_chunk_511679 | rust_dataset.txt | 511,679 | 512 | n");
assert!(residue.is_empty(), "DSR 997 reply must be fully consumed");
assert_eq!(replies.len(), 1);
match &replies[0] {
HostReply::HostTerminalThemeChanged(mode) => {
assert_eq!(*mode, zellij_utils::data::HostTerminalThemeMode::Dark);
},
other => panic!("expected Host... |
rust_dataset_chunk_511680 | rust_dataset.txt | 511,680 | 512 | => panic!("expected HostTerminalThemeChanged, got {:?}", other),
}
}
}
#[test]
fn host_theme_dsr_997_unknown_param_dropped() {
let mut parser = StdinAnsiParser::new();
// CSI ?997;3n is not a defined Dark/Light value; the parser
// recognises the CSI shape (final byte n) but
// `from_csi_r... |
rust_dataset_chunk_511681 | rust_dataset.txt | 511,681 | 512 | b"\x1b[102;133u", // captured from Konsole user
b"\x1b[A", // legacy CSI key (not Kitty kbd) — sanity
];
for kbd in &kbd_events {
let pretty = String::from_utf8_lossy(kbd).replace('\x1b', "ESC");
let mut parser = StdinAnsiParser::new();
// Pre-wedge: keypress... |
rust_dataset_chunk_511682 | rust_dataset.txt | 511,682 | 512 | StdinAnsiParser::new();
let r1 = p.feed(b"\x1b]4;1;rgb:1111");
assert!(
r1.residue.is_empty(),
"incomplete OSC 4 must not leak: {:?}",
r1.residue
);
assert!(r1.replies.is_empty());
assert_held_across_idle(&mut p);
let r2 = p.feed(b"/2222/3333\x1b\\");
assert!(
... |
rust_dataset_chunk_511683 | rust_dataset.txt | 511,683 | 512 | split.feed(b"a");
let mut combined = r1.residue.clone();
combined.extend_from_slice(&r2.residue);
assert_eq!(combined, b"\x1ba");
assert!(r2.replies.is_empty());
}
#[test]
fn fragmented_ctrl_arrow_is_retained_then_passed_through() {
let mut p = StdinAnsiParser::new();
let r1 = p.feed(b"\x1b[1;... |
rust_dataset_chunk_511684 | rust_dataset.txt | 511,684 | 512 | 97;1:3u",
b"\x1b[97:65;5u",
b"\x1b[97;5;65u",
b"\x1b[1;5A",
b"\x1b[1;2H",
b"\x1b[1;2P",
b"\x1b[1;2S",
b"\x1b[2;5~",
b"\x1b[3;5~",
b"\x1b[15;2~",
b"\x1b[27u",
b"\x1b[57362u",
b"\x1b[Z",
];
for seq in variants {
... |
rust_dataset_chunk_511685 | rust_dataset.txt | 511,685 | 512 | (),
"{} split at {}: never classified as a reply",
pretty,
split
);
}
}
}
fn keys_from_flushed_bytes(bytes: &[u8]) -> Vec<InputEvent> {
let mut parser = InputParser::new();
parser.parse_as_vec(bytes, false)
}
fn alt_char(c: char) -> Input... |
rust_dataset_chunk_511686 | rust_dataset.txt | 511,686 | 512 | assert_eq!(p.pending_partial(), PendingPartial::None);
assert_eq!(
keys_from_flushed_bytes(&drained),
vec![alt_char('[')],
"the flushed bytes must decode as Alt+[, not garbage"
);
}
#[test]
fn a_bare_csi_introducer_waits_for_the_reply_body_while_replies_are_expected() {
let mut p =... |
rust_dataset_chunk_511687 | rust_dataset.txt | 511,687 | 512 | a reply: {:?}",
out.replies
);
}
#[test]
fn startup_replies_arriving_while_a_pane_query_is_forwarded_stay_with_zellij() {
let mut p = StdinAnsiParser::new();
p.open_own_query_batch();
p.open_forward(7);
let startup = p.feed(
b"\x1b[?997;1n\x1b[4;600;800t\x1b[6;25;12t\x1b]11;rgb:11... |
rust_dataset_chunk_511688 | rust_dataset.txt | 511,688 | 512 | _is_dropped_not_given_to_the_next_pane() {
let mut p = StdinAnsiParser::new();
p.open_forward(1);
assert_eq!(p.close_forward_on_timeout(1), Some((1, Vec::new())));
p.open_forward(2);
let late = p.feed(b"\x1b]11;rgb:1111/1313/1313\x1b\\\x1b[?62;22c");
assert!(late.residue.is_empty());
assert... |
rust_dataset_chunk_511689 | rust_dataset.txt | 511,689 | 512 | byte crosses the tier boundary",
pretty
);
assert!(p.pending_partial().uses_reply_flush_guard());
assert!(
p.finalize_fast_partial().is_empty(),
"{}: the fast flush must not touch a payload-bearing partial",
pretty
);
assert_eq!(p.... |
rust_dataset_chunk_511690 | rust_dataset.txt | 511,690 | 512 | );
assert_eq!(r2.replies.len(), 1, "the rejoined OSC 4 classifies once");
match &r2.replies[0] {
HostReply::ColorRegisters(regs) => {
assert_eq!(regs[0].0, 1);
assert_eq!(regs[0].1, "rgb:1111/2222/3333");
},
other => panic!("expected ColorRegisters, got {:?}", ot... |
rust_dataset_chunk_511691 | rust_dataset.txt | 511,691 | 512 | mut p = StdinAnsiParser::new();
let mut chunk = Vec::new();
chunk.extend_from_slice(b"\x1b[200~");
chunk.extend_from_slice(b"echo \x1b]0;hi\x1b\\ done");
chunk.extend_from_slice(b"\x1b[201~");
let out = p.feed(&chunk);
assert!(
out.replies.is_empty(),
"paste content must not cla... |
rust_dataset_chunk_511692 | rust_dataset.txt | 511,692 | 512 | mut start = r1.residue.clone();
start.extend_from_slice(&r2.residue);
assert_eq!(
start, b"\x1b[200~",
"start marker passes through to residue"
);
let body = p.feed(b"\x1b]0;x\x1b\\");
assert_eq!(body.residue, b"\x1b]0;x\x1b\\");
assert!(body.rep... |
rust_dataset_chunk_511693 | rust_dataset.txt | 511,693 | 512 | _probe_ok_reply_classifies_true() {
let mut parser = StdinAnsiParser::new();
parser.expect_kitty_probe_reply();
let (replies, residue) = feed_once(&mut parser, b"\x1b_Gi=31;OK\x1b\\");
assert!(residue.is_empty(), "probe reply must be fully consumed");
assert_eq!(replies.len(), 1);
match &replies... |
rust_dataset_chunk_511694 | rust_dataset.txt | 511,694 | 512 | })
.collect();
assert_eq!(sixel_replies, vec![true]);
}
#[test]
fn primary_da_without_sixel_attribute_classifies_sixel_support_false() {
let mut parser = StdinAnsiParser::new();
let (replies, residue) = feed_once(&mut parser, b"\x1b[?62;22c");
assert!(residue.is_empty());
let sixel_... |
rust_dataset_chunk_511695 | rust_dataset.txt | 511,695 | 512 | full.len() {
let mut parser = StdinAnsiParser::new();
parser.expect_kitty_probe_reply();
let r1 = parser.feed(&full[..split]);
let r2 = parser.feed(&full[split..]);
assert!(
r1.residue.is_empty(),
"split at {}: chunk 1 residue {:?}",
split,
... |
rust_dataset_chunk_511696 | rust_dataset.txt | 511,696 | 512 | _expecting_both_kitty_probes();
let (replies, residue) = feed_once(
&mut parser,
b"\x1b_Gi=32;ENODATA:Insufficient image data\x1b\\",
);
assert!(residue.is_empty());
assert_eq!(zlib_replies(&replies), vec![false]);
}
#[test]
fn kitty_zlib_probe_absence_resolves_false_on_barrier() {
... |
rust_dataset_chunk_511697 | rust_dataset.txt | 511,697 | 512 | at {}", split);
let replies: Vec<HostReply> = r1.replies.into_iter().chain(r2.replies).collect();
assert_eq!(zlib_replies(&replies), vec![true], "split at {}", split);
}
}
#[test]
fn kitty_zlib_reply_outside_probe_window_is_not_classified() {
let mut parser = StdinAnsiParser::new();
let ou... |
rust_dataset_chunk_511698 | rust_dataset.txt | 511,698 | 512 | ]
fn unsolicited_theme_notification_classifies_without_outstanding_query() {
let mut p = StdinAnsiParser::new();
let out = p.feed(b"\x1b[?997;1n");
assert!(
out.residue.is_empty(),
"the notification must not leak as residue"
);
assert_eq!(out.replies.len(), 1);
match &out.replies... |
rust_dataset_chunk_511699 | rust_dataset.txt | 511,699 | 512 | idue() {
let (frame, payload) = announce_frame_and_payload();
let mut chunk = b"abc".to_vec();
chunk.extend_from_slice(&frame);
chunk.extend_from_slice(b"def");
let mut p = StdinAnsiParser::new();
let out = p.feed(&chunk);
assert_eq!(out.nested_frames, vec![payload]);
assert_eq!(out.resi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.