style: apply nightly rustfmt import grouping across the workspace

rustfmt.toml sets group_imports, imports_granularity and imports_layout,
which are nightly-only; agents formatted with stable rustfmt, which
ignored them. This is a formatting-only pass with `cargo +nightly fmt`.

Test Plan:
- cargo clippy --workspace --all-targets -- -D warnings
- cargo test --workspace
This commit is contained in:
ddidderr committed 2026-10-12 05:03:37 +02:00
1 parent 81d4119d85
commit 8bcb85a29a
259 files changed
+2495 -1547

No files matched your search

+6 -4
View File
@@ -6,10 +6,12 @@ use std::sync::Arc;
use ghostty_renderer::size::{GridSize, ScreenSize};
use ghostty_terminal::terminal::Terminal;
use crate::exec::{self, Exec};
use crate::sinks::SurfaceMailbox;
use crate::state::SharedState;
use crate::termio::Output;
use crate::{
exec::{self, Exec},
sinks::SurfaceMailbox,
state::SharedState,
termio::Output,
};
/// The kinds of backends.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+2 -4
View File
@@ -14,7 +14,7 @@
use std::{
ffi::{CString, NulError, c_char},
os::fd::OwnedFd,
os::{fd::OwnedFd, unix::ffi::OsStrExt},
panic::{AssertUnwindSafe, catch_unwind},
};
@@ -24,7 +24,6 @@ use rustix::{
process::{self, WaitOptions},
stdio,
};
use std::os::unix::ffi::OsStrExt;
/// Function executed /in the child process/ after the fork, but before
/// exec'ing the command. If the function returns `Some(code)`, the child
@@ -609,11 +608,10 @@ mod tests {
use std::{
fs::File,
io::{Read, Seek, SeekFrom},
os::fd::AsRawFd,
sync::Arc,
};
use std::os::fd::AsRawFd;
use ghostty_os::TempDir;
use super::*;
+35 -21
View File
@@ -15,35 +15,49 @@
//! `POLLOUT` is polled only while the queue is non-empty,
//! * termios timer: a plain deadline.
use std::collections::VecDeque;
use std::io;
use std::os::fd::{AsFd, BorrowedFd, OwnedFd};
use std::sync::Arc;
use std::thread::JoinHandle;
use std::time::{Duration, Instant};
use std::{
collections::VecDeque,
io,
os::fd::{AsFd, BorrowedFd, OwnedFd},
sync::Arc,
thread::JoinHandle,
time::{Duration, Instant},
};
use crossbeam_channel::Receiver;
use ghostty_config::command::Command as ConfigCommand;
use ghostty_config::repeatable_string_map::RepeatableStringMap;
use ghostty_config::types_b::{ShellIntegration, ShellIntegrationFeatures};
use ghostty_apprt::surface::{ChildExited, Message as SurfaceMessage};
use ghostty_config::{
command::Command as ConfigCommand,
repeatable_string_map::RepeatableStringMap,
types_b::{ShellIntegration, ShellIntegrationFeatures},
};
use ghostty_datastruct::blocking_queue::Timeout;
use ghostty_os::file::Rlimit;
use ghostty_renderer::size::{GridSize, ScreenSize};
use ghostty_terminal::terminal::Terminal;
use rustix::event::{PollFd, PollFlags};
use rustix::process::{Pid, PidfdFlags, Signal, WaitOptions};
use rustix::{
event::{PollFd, PollFlags},
process::{Pid, PidfdFlags, Signal, WaitOptions},
};
use crate::command::{
self, Command, Exit, PostForkError, RtPostForkInfo, RtPreExecInfo, linux_cgroup_post_fork,
linux_cgroup_pre_exec,
use crate::{
command::{
self,
Command,
Exit,
PostForkError,
RtPostForkInfo,
RtPreExecInfo,
linux_cgroup_post_fork,
linux_cgroup_pre_exec,
},
pty::{self, Mode, Pty, Winsize},
shell_integration::{self, EnvMap, Shell},
sinks::SurfaceMailbox,
state::{SharedState, SharedStateExt},
termio::Output,
wakeup::Wakeup,
};
use crate::pty::{self, Mode, Pty, Winsize};
use crate::shell_integration::{self, EnvMap, Shell};
use crate::sinks::SurfaceMailbox;
use crate::state::{SharedState, SharedStateExt};
use crate::termio::Output;
use crate::wakeup::Wakeup;
use ghostty_apprt::surface::{ChildExited, Message as SurfaceMessage};
/// The termios poll rate in milliseconds.
pub const TERMIOS_POLL_MS: u64 = 200;
+3 -3
View File
@@ -10,8 +10,7 @@ use std::sync::{Mutex, MutexGuard, PoisonError};
use crossbeam_channel::{Receiver, Sender, TrySendError, bounded};
use crate::message::Message;
use crate::wakeup::Wakeup;
use crate::{message::Message, wakeup::Wakeup};
/// Capacity of the queue. Hardcoded to a value that empirically has made
/// sense for Ghostty usage (`BlockingQueue(termio.Message, 64)`).
@@ -128,9 +127,10 @@ impl Mailbox {
#[cfg(test)]
mod tests {
use super::*;
use std::sync::Arc;
use super::*;
#[test]
fn send_pop_order() {
let mb = Mailbox::new().unwrap();
+7 -5
View File
@@ -6,11 +6,13 @@ use std::sync::Arc;
use ghostty_config::config::Config;
use ghostty_renderer::size::Size;
use crate::backend::Backend;
use crate::mailbox::Mailbox;
use crate::sinks::{RendererMailbox, SurfaceMailbox};
use crate::termio::DerivedConfig;
use crate::wakeup::Wakeup;
use crate::{
backend::Backend,
mailbox::Mailbox,
sinks::{RendererMailbox, SurfaceMailbox},
termio::DerivedConfig,
wakeup::Wakeup,
};
/// See the module docs.
pub struct Options<'a> {
@@ -42,8 +42,7 @@ impl Shell {
}
}
pub use ghostty_config::command::Command;
pub use ghostty_config::types_b::ShellIntegrationFeatures;
pub use ghostty_config::{command::Command, types_b::ShellIntegrationFeatures};
#[derive(Debug, thiserror::Error)]
pub enum Error {
+4 -2
View File
@@ -5,8 +5,10 @@
//! [`SharedState`]). This module only provides a convenience for termio:
//! locking the state and borrowing just the [`Terminal`].
use std::ops::{Deref, DerefMut};
use std::sync::{MutexGuard, PoisonError};
use std::{
ops::{Deref, DerefMut},
sync::{MutexGuard, PoisonError},
};
pub use ghostty_renderer::state::{SharedState, State};
use ghostty_terminal::terminal::Terminal;
+61 -34
View File
@@ -23,44 +23,67 @@
//! [`HandlerState`], which the caller flushes after unlocking
//! ([`TerminalStream::flush_outbox`]; `Termio::process_output` does this).
use std::collections::VecDeque;
use std::fmt::Write as _;
use std::sync::{Arc, OnceLock};
use std::{
collections::VecDeque,
fmt::Write as _,
sync::{Arc, OnceLock},
};
use ghostty_apprt::structs::Clipboard;
use ghostty_apprt::surface::{
DesktopNotification, Message as SurfaceMessage, ReportTitleStyle, SET_TITLE_LEN, WriteReq,
use ghostty_apprt::{
structs::Clipboard,
surface::{
DesktopNotification,
Message as SurfaceMessage,
ReportTitleStyle,
SET_TITLE_LEN,
WriteReq,
},
};
use ghostty_config::types_b::{ClipboardAccess, OSCColorReportFormat};
use ghostty_datastruct::blocking_queue::Timeout;
use ghostty_renderer::size::Size;
use ghostty_terminal::cursor::Style as CursorStyle;
use ghostty_terminal::terminal::{
DeccolmMode, Error, MouseEvents, MouseFormat, MouseShiftCapture, ScrollViewport,
SwitchScreenMode, Terminal,
use ghostty_terminal::{
cursor::Style as CursorStyle,
terminal::{
DeccolmMode,
Error,
MouseEvents,
MouseFormat,
MouseShiftCapture,
ScrollViewport,
SwitchScreenMode,
Terminal,
},
};
use ghostty_vt::ansi::{
CursorStyle as AnsiCursorStyle, DeviceAttributeReq, ModifyKeyFormat, ProtectedMode,
use ghostty_vt::{
ansi::{CursorStyle as AnsiCursorStyle, DeviceAttributeReq, ModifyKeyFormat, ProtectedMode},
apc,
color::{Dynamic as DynamicColor, Rgb},
csi,
dcs,
device_status,
kitty::{self, key::SetMode as KittySetMode},
modes::Mode,
mouse_shape::MouseShape,
osc::{
ProgressReport,
ProgressState,
Terminator,
color::{self as osc_color, Request, Target},
semantic_prompt::Action as PromptAction,
},
parser::{Dcs, Parser},
stream::{self, Action},
utf8_decoder::Utf8Decoder,
};
use ghostty_vt::color::{Dynamic as DynamicColor, Rgb};
use ghostty_vt::csi;
use ghostty_vt::device_status;
use ghostty_vt::kitty::{self, key::SetMode as KittySetMode};
use ghostty_vt::modes::Mode;
use ghostty_vt::mouse_shape::MouseShape;
use ghostty_vt::osc::color::{self as osc_color, Request, Target};
use ghostty_vt::osc::semantic_prompt::Action as PromptAction;
use ghostty_vt::osc::{ProgressReport, ProgressState, Terminator};
use ghostty_vt::parser::{Dcs, Parser};
use ghostty_vt::stream::{self, Action};
use ghostty_vt::utf8_decoder::Utf8Decoder;
use ghostty_vt::{apc, dcs};
use crate::mailbox::Mailbox;
use crate::message::{Message, SizeReport};
use crate::sinks::SurfaceMailbox;
use crate::terminfo;
use crate::wakeup::Wakeup;
use crate::{
mailbox::Mailbox,
message::{Message, SizeReport},
sinks::SurfaceMailbox,
terminfo,
wakeup::Wakeup,
};
/// `build_config.version_string`.
pub const VERSION_STRING: &str = "1.3.1";
@@ -648,8 +671,10 @@ impl StreamHandler<'_> {
fn dcs_command(&mut self, cmd: dcs::Command) {
match cmd {
dcs::Command::Tmux(tmux) => {
use ghostty_terminal::tmux::control::Notification;
use ghostty_terminal::tmux::viewer::{Action as ViewerAction, Input};
use ghostty_terminal::tmux::{
control::Notification,
viewer::{Action as ViewerAction, Input},
};
log::info!("tmux control mode event cmd={tmux:?}");
@@ -1510,10 +1535,12 @@ impl stream::Handler for StreamHandler<'_> {
#[cfg(test)]
mod tests {
use super::*;
use ghostty_terminal::terminal::Options;
use std::sync::Mutex;
use ghostty_terminal::terminal::Options;
use super::*;
/// Records surface messages.
#[derive(Default)]
struct Rec(Mutex<Vec<SurfaceMessage>>);
+1 -2
View File
@@ -6,8 +6,7 @@
//!
//! Port of `terminfo/Source.zig`.
use std::collections::HashMap;
use std::io;
use std::{collections::HashMap, io};
/// A terminfo source description.
#[derive(Debug, Clone, Copy)]
+37 -30
View File
@@ -22,39 +22,46 @@
//! Lock order is always terminal mutex first, then the stream mutex inside
//! [`Output`].
use std::io::Read;
use std::sync::{Arc, Mutex, PoisonError};
use std::time::{Duration, Instant};
use std::{
io::Read,
sync::{Arc, Mutex, MutexGuard, PoisonError},
time::{Duration, Instant},
};
use ghostty_config::conditional;
use ghostty_config::config::Config;
use ghostty_config::io::ReadableIO;
use ghostty_config::types_a::{Color, CursorStyle, TerminalColor};
use ghostty_config::types_b::{ClipboardAccess, GraphemeWidthMethod, OSCColorReportFormat};
use ghostty_config::{
conditional,
config::Config,
io::ReadableIO,
types_a::{Color, CursorStyle, TerminalColor},
types_b::{ClipboardAccess, GraphemeWidthMethod, OSCColorReportFormat},
};
use ghostty_datastruct::blocking_queue::Timeout;
use ghostty_renderer::message::Message as RendererMessage;
use ghostty_renderer::size::Size;
use ghostty_renderer::state::InspectorHook;
use ghostty_terminal::kitty::graphics_storage::TerminalInfo;
use ghostty_terminal::point::{Coordinate, Point};
use ghostty_terminal::screen::Scroll;
use ghostty_terminal::screen_set::Key as ScreenKey;
use ghostty_terminal::terminal::{Colors, Options as TerminalOptions, ScrollViewport, Terminal};
use ghostty_vt::color::{DynamicPalette, DynamicRgb, Palette};
use ghostty_vt::csi;
use ghostty_vt::kitty::graphics_command::Delete as KittyDelete;
use ghostty_vt::modes::{Mode, ModePacked};
use std::sync::MutexGuard;
use ghostty_renderer::{message::Message as RendererMessage, size::Size, state::InspectorHook};
use ghostty_terminal::{
kitty::graphics_storage::TerminalInfo,
point::{Coordinate, Point},
screen::Scroll,
screen_set::Key as ScreenKey,
terminal::{Colors, Options as TerminalOptions, ScrollViewport, Terminal},
};
use ghostty_vt::{
color::{DynamicPalette, DynamicRgb, Palette},
csi,
kitty::graphics_command::Delete as KittyDelete,
modes::{Mode, ModePacked},
};
use crate::backend::{self, Backend};
use crate::exec;
use crate::mailbox::Mailbox;
use crate::message::{Message, SizeReport};
use crate::options::Options;
use crate::sinks::{RendererMailbox, SurfaceMailbox};
use crate::state::{SharedState, SharedStateExt, State};
use crate::stream_handler::{HandlerOptions, HandlerState, TerminalStream};
use crate::wakeup::Wakeup;
use crate::{
backend::{self, Backend},
exec,
mailbox::Mailbox,
message::{Message, SizeReport},
options::Options,
sinks::{RendererMailbox, SurfaceMailbox},
state::{SharedState, SharedStateExt, State},
stream_handler::{HandlerOptions, HandlerState, TerminalStream},
wakeup::Wakeup,
};
/// Errors from termio initialization and thread setup.
#[derive(Debug, thiserror::Error)]
+13 -10
View File
@@ -18,22 +18,25 @@
//! deadlines (selection scroll, resize coalescing, synchronized-output reset,
//! termios polling). See [`Thread::thread_main`].
use std::io;
use std::time::{Duration, Instant};
use std::{
io,
time::{Duration, Instant},
};
use ghostty_apprt::surface::Message as SurfaceMessage;
use ghostty_datastruct::blocking_queue::Timeout;
use ghostty_renderer::size::Size;
use ghostty_vt::csi;
use ghostty_vt::modes::Mode;
use ghostty_vt::{csi, modes::Mode};
use rustix::event::{PollFd, PollFlags};
use crate::backend::ThreadData as BackendThreadData;
use crate::exec;
use crate::message::Message;
use crate::state::SharedStateExt;
use crate::termio::{Error, Termio, ThreadData};
use crate::wakeup::Wakeup;
use crate::{
backend::ThreadData as BackendThreadData,
exec,
message::Message,
state::SharedStateExt,
termio::{Error, Termio, ThreadData},
wakeup::Wakeup,
};
/// The number of milliseconds to coalesce certain messages like resize for.
/// Not all message types are coalesced.
+7 -4
View File
@@ -5,9 +5,11 @@
//! thread, any number of times; the waiter calls [`Wakeup::drain`] after
//! `poll` reports the fd readable.
use std::io;
use std::os::fd::{AsFd, BorrowedFd, OwnedFd};
use std::sync::Arc;
use std::{
io,
os::fd::{AsFd, BorrowedFd, OwnedFd},
sync::Arc,
};
use rustix::event::{EventfdFlags, eventfd};
@@ -74,9 +76,10 @@ impl Wakeup {
#[cfg(test)]
mod tests {
use super::*;
use rustix::event::{PollFd, PollFlags, poll};
use super::*;
fn readable(w: &Wakeup) -> bool {
let mut fds = [PollFd::from_borrowed_fd(w.as_fd(), PollFlags::IN)];
poll(