Fix compiler warnings (#4053)

* chore(cargo): Update dependencies

for xtask subcommand to remove warnings about unknown compiler
attributes.

* deps(xtask): Remove `lazy_static`

as dependency, since the code we need can now be expressed using rusts
`std` builtin types.

* fix(xtask): Hide deprecated args

so the compiler doesn't complain about dead code any more.

* fix(xtask): Remove needless borrow.

* fix: Remove dead code

across the codebase, as discovered by the rust compiler.

* fix(server): Log previously ignored errors.

* fix(xtask): Remove needless `format!` calls.

* fix(xtask): Remove superfluous return statement.

* fix(client): Remove unused enum variant

from `ClientInstruction` and all code attached to it.

* fix(server): Restore functions needed in tests.

* chore: Apply rustfmt.

* fix(server): Add missing code.

* fix: Remove leftover warnings.

* CHANGELOG: Add MR #4026.

* fix(xtask): Pin `xshell` to version 0.2.2

because release 0.2.3 changed the way stdin is handled, breaking
interactive command invocations (such as we use).
This commit is contained in:
har7an 2025-03-10 16:50:20 +00:00 committed by GitHub
parent 92e209a307
commit 502af243e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 144 additions and 207 deletions

View file

@ -44,6 +44,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* fix(grid): out of bounds removal when app does not update its scroll region on resize (https://github.com/zellij-org/zellij/pull/4045) * fix(grid): out of bounds removal when app does not update its scroll region on resize (https://github.com/zellij-org/zellij/pull/4045)
* fix(plugins): prevent paging plugins from cache at runtime (https://github.com/zellij-org/zellij/pull/4044) * fix(plugins): prevent paging plugins from cache at runtime (https://github.com/zellij-org/zellij/pull/4044)
* fix(ui): add split right/down shortcut hints to the status-bar (https://github.com/zellij-org/zellij/pull/4046) * fix(ui): add split right/down shortcut hints to the status-bar (https://github.com/zellij-org/zellij/pull/4046)
* chore(repo): remove compile warnings (https://github.com/zellij-org/zellij/pull/4026)
## [0.41.2] - 2024-11-19 ## [0.41.2] - 2024-11-19
* fix(input): keypresses not being identified properly with kitty keyboard protocol in some terminals (https://github.com/zellij-org/zellij/pull/3725) * fix(input): keypresses not being identified properly with kitty keyboard protocol in some terminals (https://github.com/zellij-org/zellij/pull/3725)

19
Cargo.lock generated
View file

@ -463,7 +463,7 @@ dependencies = [
"cap-primitives", "cap-primitives",
"cap-std", "cap-std",
"io-lifetimes 2.0.3", "io-lifetimes 2.0.3",
"windows-sys 0.52.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -491,7 +491,7 @@ dependencies = [
"ipnet", "ipnet",
"maybe-owned", "maybe-owned",
"rustix 0.38.44", "rustix 0.38.44",
"windows-sys 0.52.0", "windows-sys 0.59.0",
"winx", "winx",
] ]
@ -1171,7 +1171,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.52.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -1852,7 +1852,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2285ddfe3054097ef4b2fe909ef8c3bcd1ea52a8f0d274416caebeef39f04a65" checksum = "2285ddfe3054097ef4b2fe909ef8c3bcd1ea52a8f0d274416caebeef39f04a65"
dependencies = [ dependencies = [
"io-lifetimes 2.0.3", "io-lifetimes 2.0.3",
"windows-sys 0.52.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -3173,7 +3173,7 @@ dependencies = [
"libc", "libc",
"linux-raw-sys 0.4.15", "linux-raw-sys 0.4.15",
"once_cell", "once_cell",
"windows-sys 0.52.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -5102,18 +5102,18 @@ dependencies = [
[[package]] [[package]]
name = "xflags" name = "xflags"
version = "0.3.1" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4554b580522d0ca238369c16b8f6ce34524d61dafe7244993754bbd05f2c2ea" checksum = "7d9e15fbb3de55454b0106e314b28e671279009b363e6f1d8e39fdc3bf048944"
dependencies = [ dependencies = [
"xflags-macros", "xflags-macros",
] ]
[[package]] [[package]]
name = "xflags-macros" name = "xflags-macros"
version = "0.3.1" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f58e7b3ca8977093aae6b87b6a7730216fc4c53a6530bab5c43a783cd810c1a8" checksum = "672423d4fea7ffa2f6c25ba60031ea13dc6258070556f125cc4d790007d4a155"
[[package]] [[package]]
name = "xshell" name = "xshell"
@ -5135,7 +5135,6 @@ name = "xtask"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"lazy_static",
"prost-build", "prost-build",
"toml 0.5.10", "toml 0.5.10",
"which", "which",

View file

@ -6,9 +6,14 @@ edition = "2021"
[dependencies] [dependencies]
anyhow = "1.0" anyhow = "1.0"
lazy_static = "1.4" # TODO(hartan): Update this once we get a new release. See:
# <https://github.com/matklad/xshell/issues/63>
xshell = "= 0.2.2" xshell = "= 0.2.2"
xflags = "0.3.1" xflags = "0.3.2"
which = "4.2" which = "4.2"
toml = "0.5" toml = "0.5"
prost-build = "0.11.9" prost-build = "0.11.9"
[lints.rust]
# Only required because we need to fix `xshell` to `=0.2.2`
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(trick_rust_analyzer_into_highlighting_interpolated_bits)'] }

View file

@ -22,7 +22,7 @@ pub fn build(sh: &Shell, flags: flags::Build) -> anyhow::Result<()> {
std::process::exit(1); std::process::exit(1);
} }
for WorkspaceMember { crate_name, .. } in crate::WORKSPACE_MEMBERS for WorkspaceMember { crate_name, .. } in crate::workspace_members()
.iter() .iter()
.filter(|member| member.build) .filter(|member| member.build)
{ {
@ -32,10 +32,8 @@ pub fn build(sh: &Shell, flags: flags::Build) -> anyhow::Result<()> {
if flags.no_plugins { if flags.no_plugins {
continue; continue;
} }
} else { } else if flags.plugins_only {
if flags.plugins_only { continue;
continue;
}
} }
// zellij-utils requires protobuf definition files to be present. Usually these are // zellij-utils requires protobuf definition files to be present. Usually these are
@ -153,7 +151,7 @@ pub fn manpage(sh: &Shell) -> anyhow::Result<()> {
let project_root = crate::project_root(); let project_root = crate::project_root();
let asset_dir = &project_root.join("assets").join("man"); let asset_dir = &project_root.join("assets").join("man");
sh.create_dir(&asset_dir).context(err_context)?; sh.create_dir(asset_dir).context(err_context)?;
let _pd = sh.push_dir(asset_dir); let _pd = sh.push_dir(asset_dir);
cmd!(sh, "{mandown} {project_root}/docs/MANPAGE.md 1") cmd!(sh, "{mandown} {project_root}/docs/MANPAGE.md 1")

View file

@ -77,7 +77,7 @@ fn e2e_build(sh: &Shell) -> anyhow::Result<()> {
sh.remove_path(&data_dir) sh.remove_path(&data_dir)
.and_then(|_| sh.create_dir(&data_dir)) .and_then(|_| sh.create_dir(&data_dir))
.and_then(|_| sh.create_dir(&data_dir.join("plugins"))) .and_then(|_| sh.create_dir(data_dir.join("plugins")))
.context(err_context)?; .context(err_context)?;
for plugin in plugins { for plugin in plugins {
@ -119,15 +119,15 @@ fn e2e_test(sh: &Shell, args: Vec<OsString>) -> anyhow::Result<()> {
// plugin system tests are run here because they're medium-slow // plugin system tests are run here because they're medium-slow
let _pd = sh.push_dir(Path::new("zellij-server")); let _pd = sh.push_dir(Path::new("zellij-server"));
println!(""); println!();
let msg = format!(">> Testing Plugin System"); let msg = ">> Testing Plugin System".to_string();
crate::status(&msg); crate::status(&msg);
println!("{}", msg); println!("{}", msg);
cmd!(sh, "{cargo} test -- --ignored --nocapture --test-threads 1") cmd!(sh, "{cargo} test -- --ignored --nocapture --test-threads 1")
.args(args.clone()) .args(args.clone())
.run() .run()
.with_context(|| format!("Failed to run tests for the Plugin System"))?; .with_context(|| "Failed to run tests for the Plugin System".to_string())?;
Ok(()) Ok(())
}) })
.context(err_context) .context(err_context)

View file

@ -21,7 +21,7 @@ pub fn clippy(sh: &Shell, _flags: flags::Clippy) -> anyhow::Result<()> {
.and_then(|_| crate::cargo()) .and_then(|_| crate::cargo())
.context("failed to run task 'clippy'")?; .context("failed to run task 'clippy'")?;
for WorkspaceMember { crate_name, .. } in crate::WORKSPACE_MEMBERS.iter() { for WorkspaceMember { crate_name, .. } in crate::workspace_members().iter() {
let _pd = sh.push_dir(Path::new(crate_name)); let _pd = sh.push_dir(Path::new(crate_name));
// Tell the user where we are now // Tell the user where we are now
println!(); println!();

View file

@ -9,7 +9,7 @@ xflags::xflags! {
cmd xtask { cmd xtask {
/// Deprecation warning. Compatibility to transition from `cargo make`. /// Deprecation warning. Compatibility to transition from `cargo make`.
cmd deprecated { cmd deprecated {
repeated args: OsString repeated _args: OsString
} }
/// Tasks for the CI /// Tasks for the CI
@ -128,7 +128,7 @@ pub enum XtaskCmd {
#[derive(Debug)] #[derive(Debug)]
pub struct Deprecated { pub struct Deprecated {
pub args: Vec<OsString>, pub _args: Vec<OsString>,
} }
#[derive(Debug)] #[derive(Debug)]

View file

@ -11,7 +11,7 @@ pub fn format(sh: &Shell, flags: flags::Format) -> anyhow::Result<()> {
.and_then(|_| crate::cargo()) .and_then(|_| crate::cargo())
.context("failed to run task 'format'")?; .context("failed to run task 'format'")?;
for WorkspaceMember { crate_name, .. } in crate::WORKSPACE_MEMBERS.iter() { for WorkspaceMember { crate_name, .. } in crate::workspace_members().iter() {
let _pd = sh.push_dir(Path::new(crate_name)); let _pd = sh.push_dir(Path::new(crate_name));
// Tell the user where we are now // Tell the user where we are now
println!(); println!();

View file

@ -19,6 +19,7 @@ use anyhow::Context;
use std::{ use std::{
env, env,
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::OnceLock,
time::Instant, time::Instant,
}; };
use xshell::Shell; use xshell::Shell;
@ -28,24 +29,72 @@ pub struct WorkspaceMember {
build: bool, build: bool,
} }
lazy_static::lazy_static! { fn workspace_members() -> &'static Vec<WorkspaceMember> {
pub static ref WORKSPACE_MEMBERS: Vec<WorkspaceMember> = vec![ static WORKSPACE_MEMBERS: OnceLock<Vec<WorkspaceMember>> = OnceLock::new();
WorkspaceMember{crate_name: "default-plugins/compact-bar", build: true}, WORKSPACE_MEMBERS.get_or_init(|| {
WorkspaceMember{crate_name: "default-plugins/status-bar", build: true}, vec![
WorkspaceMember{crate_name: "default-plugins/strider", build: true}, WorkspaceMember {
WorkspaceMember{crate_name: "default-plugins/tab-bar", build: true}, crate_name: "default-plugins/compact-bar",
WorkspaceMember{crate_name: "default-plugins/fixture-plugin-for-tests", build: true}, build: true,
WorkspaceMember{crate_name: "default-plugins/session-manager", build: true}, },
WorkspaceMember{crate_name: "default-plugins/configuration", build: true}, WorkspaceMember {
WorkspaceMember{crate_name: "default-plugins/plugin-manager", build: true}, crate_name: "default-plugins/status-bar",
WorkspaceMember{crate_name: "default-plugins/about", build: true}, build: true,
WorkspaceMember{crate_name: "zellij-utils", build: false}, },
WorkspaceMember{crate_name: "zellij-tile-utils", build: false}, WorkspaceMember {
WorkspaceMember{crate_name: "zellij-tile", build: false}, crate_name: "default-plugins/strider",
WorkspaceMember{crate_name: "zellij-client", build: false}, build: true,
WorkspaceMember{crate_name: "zellij-server", build: false}, },
WorkspaceMember{crate_name: ".", build: true}, WorkspaceMember {
]; crate_name: "default-plugins/tab-bar",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/fixture-plugin-for-tests",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/session-manager",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/configuration",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/plugin-manager",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/about",
build: true,
},
WorkspaceMember {
crate_name: "zellij-utils",
build: false,
},
WorkspaceMember {
crate_name: "zellij-tile-utils",
build: false,
},
WorkspaceMember {
crate_name: "zellij-tile",
build: false,
},
WorkspaceMember {
crate_name: "zellij-client",
build: false,
},
WorkspaceMember {
crate_name: "zellij-server",
build: false,
},
WorkspaceMember {
crate_name: ".",
build: true,
},
]
})
} }
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {

View file

@ -317,7 +317,7 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> {
} }
// Publish all the crates // Publish all the crates
for WorkspaceMember { crate_name, .. } in crate::WORKSPACE_MEMBERS.iter() { for WorkspaceMember { crate_name, .. } in crate::workspace_members().iter() {
if crate_name.contains("plugin") || crate_name.contains("xtask") { if crate_name.contains("plugin") || crate_name.contains("xtask") {
continue; continue;
} }

View file

@ -20,15 +20,15 @@ pub fn test(sh: &Shell, flags: flags::Test) -> anyhow::Result<()> {
) )
.context(err_context)?; .context(err_context)?;
for WorkspaceMember { crate_name, .. } in crate::WORKSPACE_MEMBERS.iter() { for WorkspaceMember { crate_name, .. } in crate::workspace_members().iter() {
// the workspace root only contains e2e tests, skip it // the workspace root only contains e2e tests, skip it
if *crate_name == "." { if crate_name == &"." {
continue; continue;
} }
let _pd = sh.push_dir(Path::new(crate_name)); let _pd = sh.push_dir(Path::new(crate_name));
// Tell the user where we are now // Tell the user where we are now
println!(""); println!();
let msg = format!(">> Testing '{}'", crate_name); let msg = format!(">> Testing '{}'", crate_name);
crate::status(&msg); crate::status(&msg);
println!("{}", msg); println!("{}", msg);
@ -60,9 +60,9 @@ pub fn host_target_triple(sh: &Shell) -> anyhow::Result<String> {
return None; return None;
} }
if let Some((_, triple)) = line.split_once(": ") { if let Some((_, triple)) = line.split_once(": ") {
return Some(triple.to_string()); Some(triple.to_string())
} else { } else {
return None; None
} }
}) })
.collect::<Vec<String>>(); .collect::<Vec<String>>();

View file

@ -46,15 +46,14 @@ pub(crate) enum ClientInstruction {
UnblockInputThread, UnblockInputThread,
Exit(ExitReason), Exit(ExitReason),
Connected, Connected,
ActiveClients(Vec<ClientId>),
StartedParsingStdinQuery, StartedParsingStdinQuery,
DoneParsingStdinQuery, DoneParsingStdinQuery,
Log(Vec<String>), Log(Vec<String>),
LogError(Vec<String>), LogError(Vec<String>),
SwitchSession(ConnectToSession), SwitchSession(ConnectToSession),
SetSynchronizedOutput(Option<SyncOutput>), SetSynchronizedOutput(Option<SyncOutput>),
UnblockCliPipeInput(String), // String -> pipe name UnblockCliPipeInput(()), // String -> pipe name
CliPipeOutput(String, String), // String -> pipe name, String -> output CliPipeOutput((), ()), // String -> pipe name, String -> output
QueryTerminalSize, QueryTerminalSize,
WriteConfigToDisk { config: String }, WriteConfigToDisk { config: String },
} }
@ -66,17 +65,16 @@ impl From<ServerToClientMsg> for ClientInstruction {
ServerToClientMsg::Render(buffer) => ClientInstruction::Render(buffer), ServerToClientMsg::Render(buffer) => ClientInstruction::Render(buffer),
ServerToClientMsg::UnblockInputThread => ClientInstruction::UnblockInputThread, ServerToClientMsg::UnblockInputThread => ClientInstruction::UnblockInputThread,
ServerToClientMsg::Connected => ClientInstruction::Connected, ServerToClientMsg::Connected => ClientInstruction::Connected,
ServerToClientMsg::ActiveClients(clients) => ClientInstruction::ActiveClients(clients),
ServerToClientMsg::Log(log_lines) => ClientInstruction::Log(log_lines), ServerToClientMsg::Log(log_lines) => ClientInstruction::Log(log_lines),
ServerToClientMsg::LogError(log_lines) => ClientInstruction::LogError(log_lines), ServerToClientMsg::LogError(log_lines) => ClientInstruction::LogError(log_lines),
ServerToClientMsg::SwitchSession(connect_to_session) => { ServerToClientMsg::SwitchSession(connect_to_session) => {
ClientInstruction::SwitchSession(connect_to_session) ClientInstruction::SwitchSession(connect_to_session)
}, },
ServerToClientMsg::UnblockCliPipeInput(pipe_name) => { ServerToClientMsg::UnblockCliPipeInput(_pipe_name) => {
ClientInstruction::UnblockCliPipeInput(pipe_name) ClientInstruction::UnblockCliPipeInput(())
}, },
ServerToClientMsg::CliPipeOutput(pipe_name, output) => { ServerToClientMsg::CliPipeOutput(_pipe_name, _output) => {
ClientInstruction::CliPipeOutput(pipe_name, output) ClientInstruction::CliPipeOutput((), ())
}, },
ServerToClientMsg::QueryTerminalSize => ClientInstruction::QueryTerminalSize, ServerToClientMsg::QueryTerminalSize => ClientInstruction::QueryTerminalSize,
ServerToClientMsg::WriteConfigToDisk { config } => { ServerToClientMsg::WriteConfigToDisk { config } => {
@ -94,7 +92,6 @@ impl From<&ClientInstruction> for ClientContext {
ClientInstruction::Render(_) => ClientContext::Render, ClientInstruction::Render(_) => ClientContext::Render,
ClientInstruction::UnblockInputThread => ClientContext::UnblockInputThread, ClientInstruction::UnblockInputThread => ClientContext::UnblockInputThread,
ClientInstruction::Connected => ClientContext::Connected, ClientInstruction::Connected => ClientContext::Connected,
ClientInstruction::ActiveClients(_) => ClientContext::ActiveClients,
ClientInstruction::Log(_) => ClientContext::Log, ClientInstruction::Log(_) => ClientContext::Log,
ClientInstruction::LogError(_) => ClientContext::LogError, ClientInstruction::LogError(_) => ClientContext::LogError,
ClientInstruction::StartedParsingStdinQuery => ClientContext::StartedParsingStdinQuery, ClientInstruction::StartedParsingStdinQuery => ClientContext::StartedParsingStdinQuery,

View file

@ -92,7 +92,6 @@ pub enum ServerInstruction {
ClientId, ClientId,
), ),
ConnStatus(ClientId), ConnStatus(ClientId),
ActiveClients(ClientId),
Log(Vec<String>, ClientId), Log(Vec<String>, ClientId),
LogError(Vec<String>, ClientId), LogError(Vec<String>, ClientId),
SwitchSession(ConnectToSession, ClientId), SwitchSession(ConnectToSession, ClientId),
@ -133,7 +132,6 @@ impl From<&ServerInstruction> for ServerContext {
ServerInstruction::DetachSession(..) => ServerContext::DetachSession, ServerInstruction::DetachSession(..) => ServerContext::DetachSession,
ServerInstruction::AttachClient(..) => ServerContext::AttachClient, ServerInstruction::AttachClient(..) => ServerContext::AttachClient,
ServerInstruction::ConnStatus(..) => ServerContext::ConnStatus, ServerInstruction::ConnStatus(..) => ServerContext::ConnStatus,
ServerInstruction::ActiveClients(_) => ServerContext::ActiveClients,
ServerInstruction::Log(..) => ServerContext::Log, ServerInstruction::Log(..) => ServerContext::Log,
ServerInstruction::LogError(..) => ServerContext::LogError, ServerInstruction::LogError(..) => ServerContext::LogError,
ServerInstruction::SwitchSession(..) => ServerContext::SwitchSession, ServerInstruction::SwitchSession(..) => ServerContext::SwitchSession,
@ -1045,15 +1043,6 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
let _ = os_input.send_to_client(client_id, ServerToClientMsg::Connected); let _ = os_input.send_to_client(client_id, ServerToClientMsg::Connected);
remove_client!(client_id, os_input, session_state); remove_client!(client_id, os_input, session_state);
}, },
ServerInstruction::ActiveClients(client_id) => {
let client_ids = session_state.read().unwrap().client_ids();
send_to_client!(
client_id,
os_input,
ServerToClientMsg::ActiveClients(client_ids),
session_state
);
},
ServerInstruction::Log(lines_to_log, client_id) => { ServerInstruction::Log(lines_to_log, client_id) => {
send_to_client!( send_to_client!(
client_id, client_id,

View file

@ -2033,8 +2033,11 @@ impl<'a> TiledPaneGrid<'a> {
return None; return None;
} }
StackedPanes::new(self.panes.clone()) StackedPanes::new(self.panes.clone())
.combine_vertically_aligned_panes_to_stack(&pane_id, neighboring_pane_ids_above); .combine_vertically_aligned_panes_to_stack(&pane_id, neighboring_pane_ids_above)
StackedPanes::new(self.panes.clone()).expand_pane(&pane_id); .non_fatal();
StackedPanes::new(self.panes.clone())
.expand_pane(&pane_id)
.non_fatal();
Some(vec![*pane_id]) Some(vec![*pane_id])
} }
pub fn unstack_pane_up(&mut self, pane_id: &PaneId) -> Option<Vec<PaneId>> { pub fn unstack_pane_up(&mut self, pane_id: &PaneId) -> Option<Vec<PaneId>> {
@ -2114,8 +2117,11 @@ impl<'a> TiledPaneGrid<'a> {
return None; return None;
} }
StackedPanes::new(self.panes.clone()) StackedPanes::new(self.panes.clone())
.combine_vertically_aligned_panes_to_stack(&pane_id, neighboring_pane_ids_below); .combine_vertically_aligned_panes_to_stack(&pane_id, neighboring_pane_ids_below)
StackedPanes::new(self.panes.clone()).expand_pane(&pane_id); .non_fatal();
StackedPanes::new(self.panes.clone())
.expand_pane(&pane_id)
.non_fatal();
Some(vec![*pane_id]) Some(vec![*pane_id])
} }
pub fn direct_neighboring_pane_ids_to_the_left(&self, root_pane_id: &PaneId) -> Vec<PaneId> { pub fn direct_neighboring_pane_ids_to_the_left(&self, root_pane_id: &PaneId) -> Vec<PaneId> {
@ -2184,11 +2190,12 @@ impl<'a> TiledPaneGrid<'a> {
{ {
return None; return None;
} }
StackedPanes::new(self.panes.clone()).combine_horizontally_aligned_panes_to_stack( StackedPanes::new(self.panes.clone())
&pane_id, .combine_horizontally_aligned_panes_to_stack(&pane_id, neighboring_pane_ids_to_the_left)
neighboring_pane_ids_to_the_left, .non_fatal();
); StackedPanes::new(self.panes.clone())
StackedPanes::new(self.panes.clone()).expand_pane(&pane_id); .expand_pane(&pane_id)
.non_fatal();
Some(vec![*pane_id]) Some(vec![*pane_id])
} }
pub fn direct_neighboring_pane_ids_to_the_right(&self, root_pane_id: &PaneId) -> Vec<PaneId> { pub fn direct_neighboring_pane_ids_to_the_right(&self, root_pane_id: &PaneId) -> Vec<PaneId> {
@ -2260,11 +2267,15 @@ impl<'a> TiledPaneGrid<'a> {
if neighboring_pane_ids_to_the_right.is_empty() { if neighboring_pane_ids_to_the_right.is_empty() {
return None; return None;
} }
StackedPanes::new(self.panes.clone()).combine_horizontally_aligned_panes_to_stack( StackedPanes::new(self.panes.clone())
&pane_id, .combine_horizontally_aligned_panes_to_stack(
neighboring_pane_ids_to_the_right, &pane_id,
); neighboring_pane_ids_to_the_right,
StackedPanes::new(self.panes.clone()).expand_pane(&pane_id); )
.non_fatal();
StackedPanes::new(self.panes.clone())
.expand_pane(&pane_id)
.non_fatal();
Some(vec![*pane_id]) Some(vec![*pane_id])
} }
pub fn next_stack_id(&self) -> usize { pub fn next_stack_id(&self) -> usize {
@ -2282,74 +2293,6 @@ impl<'a> TiledPaneGrid<'a> {
.set_geom(geom_of_active_pane); .set_geom(geom_of_active_pane);
Ok(()) Ok(())
} }
fn get_vertically_aligned_pane_id_above(&self, pane_id: &PaneId) -> Option<PaneId> {
let Some(pane_geom) = self.get_pane_geom(pane_id) else {
return None;
};
let panes = self.panes.borrow();
let stacked_panes = StackedPanes::new(self.panes.clone());
let pane_geom = if pane_geom.is_stacked() {
stacked_panes
.position_and_size_of_stack(pane_id)
.unwrap_or(pane_geom)
} else {
pane_geom
};
panes.iter().find_map(|(candidate_pane_id, p)| {
if !p.selectable() {
return None;
}
let candidate_geom = p.current_geom();
let candidate_geom = if candidate_geom.is_stacked() {
stacked_panes
.position_and_size_of_stack(candidate_pane_id)
.unwrap_or(candidate_geom)
} else {
candidate_geom
};
if candidate_geom.y + candidate_geom.rows.as_usize() == pane_geom.y
&& candidate_geom.x == pane_geom.x
&& candidate_geom.cols.as_usize() == pane_geom.cols.as_usize()
{
return Some(p.pid());
}
return None;
})
}
fn get_vertically_aligned_pane_id_below(&self, pane_id: &PaneId) -> Option<PaneId> {
let Some(pane_geom) = self.get_pane_geom(pane_id) else {
return None;
};
let panes = self.panes.borrow();
let stacked_panes = StackedPanes::new(self.panes.clone());
let pane_geom = if pane_geom.is_stacked() {
stacked_panes
.position_and_size_of_stack(pane_id)
.unwrap_or(pane_geom)
} else {
pane_geom
};
panes.iter().find_map(|(candidate_pane_id, p)| {
if !p.selectable() {
return None;
}
let candidate_geom = p.current_geom();
let candidate_geom = if candidate_geom.is_stacked() {
stacked_panes
.position_and_size_of_stack(candidate_pane_id)
.unwrap_or(candidate_geom)
} else {
candidate_geom
};
if candidate_geom.y == pane_geom.y + pane_geom.rows.as_usize()
&& candidate_geom.x == pane_geom.x
&& candidate_geom.cols.as_usize() == pane_geom.cols.as_usize()
{
return Some(p.pid());
}
return None;
})
}
} }
pub fn split(direction: SplitDirection, rect: &PaneGeom) -> Option<(PaneGeom, PaneGeom)> { pub fn split(direction: SplitDirection, rect: &PaneGeom) -> Option<(PaneGeom, PaneGeom)> {

View file

@ -639,7 +639,6 @@ impl<'a> PluginLoader<'a> {
.filter_map(|export| export.clone().into_func().map(|_| export.name())) .filter_map(|export| export.clone().into_func().map(|_| export.name()))
{ {
if function_name.ends_with("_worker") { if function_name.ends_with("_worker") {
let plugin_config = self.plugin.clone();
let (mut store, instance) = let (mut store, instance) =
self.create_plugin_instance_and_wasi_env_for_worker()?; self.create_plugin_instance_and_wasi_env_for_worker()?;
@ -650,7 +649,7 @@ impl<'a> PluginLoader<'a> {
.call(&mut store, ()) .call(&mut store, ())
.with_context(err_context)?; .with_context(err_context)?;
let worker = RunningWorker::new(store, instance, &function_name, plugin_config); let worker = RunningWorker::new(store, instance, &function_name);
let worker_sender = plugin_worker(worker); let worker_sender = plugin_worker(worker);
workers.insert(function_name.into(), worker_sender); workers.insert(function_name.into(), worker_sender);
} }

View file

@ -5,29 +5,21 @@ use wasmtime::{Instance, Store};
use zellij_utils::async_channel::{unbounded, Receiver, Sender}; use zellij_utils::async_channel::{unbounded, Receiver, Sender};
use zellij_utils::async_std::task; use zellij_utils::async_std::task;
use zellij_utils::errors::prelude::*; use zellij_utils::errors::prelude::*;
use zellij_utils::input::plugins::PluginConfig;
use zellij_utils::plugin_api::message::ProtobufMessage; use zellij_utils::plugin_api::message::ProtobufMessage;
use zellij_utils::prost::Message; use zellij_utils::prost::Message;
pub struct RunningWorker { pub struct RunningWorker {
pub instance: Instance, pub instance: Instance,
pub name: String, pub name: String,
pub plugin_config: PluginConfig,
pub store: Store<PluginEnv>, pub store: Store<PluginEnv>,
} }
impl RunningWorker { impl RunningWorker {
pub fn new( pub fn new(store: Store<PluginEnv>, instance: Instance, name: &str) -> Self {
store: Store<PluginEnv>,
instance: Instance,
name: &str,
plugin_config: PluginConfig,
) -> Self {
RunningWorker { RunningWorker {
store, store,
instance, instance,
name: name.into(), name: name.into(),
plugin_config,
} }
} }
pub fn send_message(&mut self, message: String, payload: String) -> Result<()> { pub fn send_message(&mut self, message: String, payload: String) -> Result<()> {

View file

@ -1188,9 +1188,6 @@ pub(crate) fn route_thread_main(
let _ = to_server.send(ServerInstruction::DetachSession(client_id)); let _ = to_server.send(ServerInstruction::DetachSession(client_id));
should_break = true; should_break = true;
}, },
ClientToServerMsg::ListClients => {
let _ = to_server.send(ServerInstruction::ActiveClients(client_id));
},
ClientToServerMsg::ConfigWrittenToDisk(config) => { ClientToServerMsg::ConfigWrittenToDisk(config) => {
let _ = to_server let _ = to_server
.send(ServerInstruction::ConfigWrittenToDisk(client_id, config)); .send(ServerInstruction::ConfigWrittenToDisk(client_id, config));

View file

@ -186,7 +186,6 @@ pub(crate) struct Tab {
viewport: Rc<RefCell<Viewport>>, // includes all non-UI panes viewport: Rc<RefCell<Viewport>>, // includes all non-UI panes
display_area: Rc<RefCell<Size>>, // includes all panes (including eg. the status bar and tab bar in the default layout) display_area: Rc<RefCell<Size>>, // includes all panes (including eg. the status bar and tab bar in the default layout)
character_cell_size: Rc<RefCell<Option<SizeInPixels>>>, character_cell_size: Rc<RefCell<Option<SizeInPixels>>>,
stacked_resize: Rc<RefCell<bool>>,
sixel_image_store: Rc<RefCell<SixelImageStore>>, sixel_image_store: Rc<RefCell<SixelImageStore>>,
os_api: Box<dyn ServerOsApi>, os_api: Box<dyn ServerOsApi>,
pub senders: ThreadSenders, pub senders: ThreadSenders,
@ -206,7 +205,6 @@ pub(crate) struct Tab {
// it seems that optimization is possible using `active_panes` // it seems that optimization is possible using `active_panes`
focus_pane_id: Option<PaneId>, focus_pane_id: Option<PaneId>,
copy_on_select: bool, copy_on_select: bool,
last_mouse_hold_position: Option<Position>,
terminal_emulator_colors: Rc<RefCell<Palette>>, terminal_emulator_colors: Rc<RefCell<Palette>>,
terminal_emulator_color_codes: Rc<RefCell<HashMap<usize, String>>>, terminal_emulator_color_codes: Rc<RefCell<HashMap<usize, String>>>,
pids_waiting_resize: HashSet<u32>, // u32 is the terminal_id pids_waiting_resize: HashSet<u32>, // u32 is the terminal_id
@ -691,7 +689,6 @@ impl Tab {
viewport, viewport,
display_area, display_area,
character_cell_size, character_cell_size,
stacked_resize,
sixel_image_store, sixel_image_store,
synchronize_is_active: false, synchronize_is_active: false,
os_api, os_api,
@ -709,7 +706,6 @@ impl Tab {
clipboard_provider, clipboard_provider,
focus_pane_id: None, focus_pane_id: None,
copy_on_select: copy_options.copy_on_select, copy_on_select: copy_options.copy_on_select,
last_mouse_hold_position: None,
terminal_emulator_colors, terminal_emulator_colors,
terminal_emulator_color_codes, terminal_emulator_color_codes,
pids_waiting_resize: HashSet::new(), pids_waiting_resize: HashSet::new(),
@ -3898,6 +3894,7 @@ impl Tab {
Ok(()) Ok(())
} }
#[cfg(test)]
pub fn handle_right_mouse_release( pub fn handle_right_mouse_release(
&mut self, &mut self,
position: &Position, position: &Position,
@ -3907,7 +3904,6 @@ impl Tab {
format!("failed to handle right mouse release at position {position:?} for client {client_id}") format!("failed to handle right mouse release at position {position:?} for client {client_id}")
}; };
self.last_mouse_hold_position = None;
let active_pane = self.get_active_pane_or_floating_pane_mut(client_id); let active_pane = self.get_active_pane_or_floating_pane_mut(client_id);
if let Some(active_pane) = active_pane { if let Some(active_pane) = active_pane {
let mut relative_position = active_pane.relative_position(position); let mut relative_position = active_pane.relative_position(position);
@ -3931,6 +3927,7 @@ impl Tab {
Ok(()) Ok(())
} }
#[cfg(test)]
fn handle_middle_mouse_release( fn handle_middle_mouse_release(
&mut self, &mut self,
position: &Position, position: &Position,
@ -3940,7 +3937,6 @@ impl Tab {
format!("failed to handle middle mouse release at position {position:?} for client {client_id}") format!("failed to handle middle mouse release at position {position:?} for client {client_id}")
}; };
self.last_mouse_hold_position = None;
let active_pane = self.get_active_pane_or_floating_pane_mut(client_id); let active_pane = self.get_active_pane_or_floating_pane_mut(client_id);
if let Some(active_pane) = active_pane { if let Some(active_pane) = active_pane {
let mut relative_position = active_pane.relative_position(position); let mut relative_position = active_pane.relative_position(position);

View file

@ -64,9 +64,6 @@ impl SwapLayouts {
pub fn reset_floating_damage(&mut self) { pub fn reset_floating_damage(&mut self) {
self.is_floating_damaged = false; self.is_floating_damaged = false;
} }
pub fn reset_tiled_damage(&mut self) {
self.is_tiled_damaged = false;
}
pub fn is_floating_damaged(&self) -> bool { pub fn is_floating_damaged(&self) -> bool {
self.is_floating_damaged self.is_floating_damaged
} }
@ -280,31 +277,4 @@ impl SwapLayouts {
} }
None None
} }
pub fn best_effort_tiled_layout(
&mut self,
tiled_panes: &TiledPanes,
) -> Option<TiledPaneLayout> {
for swap_layout in self.swap_tiled_layouts.iter() {
for (_constraint, layout) in swap_layout.0.iter() {
let focus_layout_if_not_focused = true;
let display_area = self.display_area.borrow();
// TODO: reuse the assets from position_panes_in_space here?
let pane_count = tiled_panes.visible_panes_count();
let display_area = PaneGeom::from(&*display_area);
if layout
.position_panes_in_space(
&display_area,
Some(pane_count),
false,
focus_layout_if_not_focused,
)
.is_ok()
{
return Some(layout.clone());
}
}
}
log::error!("Could not find layout that would fit on screen!");
None
}
} }

View file

@ -82,7 +82,13 @@ impl TerminalBytes {
let mut buf = [0u8; 65536]; let mut buf = [0u8; 65536];
loop { loop {
match self.deadline_read(&mut buf).await { match self.deadline_read(&mut buf).await {
ReadResult::Ok(0) | ReadResult::Err(_) => break, // EOF or error // EOF
ReadResult::Ok(0) => break,
// Some error occured
ReadResult::Err(err) => {
log::error!("{}", err);
break;
},
ReadResult::Timeout => { ReadResult::Timeout => {
let time_to_send_render = self let time_to_send_render = self
.async_send_to_screen(ScreenInstruction::Render) .async_send_to_screen(ScreenInstruction::Render)

View file

@ -450,7 +450,6 @@ pub enum ClientContext {
ServerError, ServerError,
SwitchToMode, SwitchToMode,
Connected, Connected,
ActiveClients,
Log, Log,
LogError, LogError,
OwnClientId, OwnClientId,
@ -477,7 +476,6 @@ pub enum ServerContext {
DetachSession, DetachSession,
AttachClient, AttachClient,
ConnStatus, ConnStatus,
ActiveClients,
Log, Log,
LogError, LogError,
SwitchSession, SwitchSession,

View file

@ -92,7 +92,6 @@ pub enum ClientToServerMsg {
ClientExited, ClientExited,
KillSession, KillSession,
ConnStatus, ConnStatus,
ListClients,
ConfigWrittenToDisk(Config), ConfigWrittenToDisk(Config),
FailedToWriteConfigToDisk(Option<PathBuf>), FailedToWriteConfigToDisk(Option<PathBuf>),
} }
@ -104,7 +103,6 @@ pub enum ServerToClientMsg {
UnblockInputThread, UnblockInputThread,
Exit(ExitReason), Exit(ExitReason),
Connected, Connected,
ActiveClients(Vec<ClientId>),
Log(Vec<String>), Log(Vec<String>),
LogError(Vec<String>), LogError(Vec<String>),
SwitchSession(ConnectToSession), SwitchSession(ConnectToSession),