aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src
diff options
context:
space:
mode:
authorSimoyd <sirnoyd@gmail.com>2026-04-29 09:39:38 -0400
committerGitHub <noreply@github.com>2026-04-29 15:39:38 +0200
commit71e388a2e2bb2bfa9239a669c450130a81699489 (patch)
tree58e86f5cd0fe4b0e116c372c8e671aab0d9d05df /zellij-server/src
parentUpdate CHANGELOG.md (diff)
downloadsl0ppij-71e388a2e2bb2bfa9239a669c450130a81699489.tar.gz
sl0ppij-71e388a2e2bb2bfa9239a669c450130a81699489.tar.xz
sl0ppij-71e388a2e2bb2bfa9239a669c450130a81699489.zip
fix(windows): stop reusing terminal pane ids (#5082)
Prevent late ClosePane events from closing newly spawned panes by making Windows terminal IDs monotonic. This matches the Unix backend and avoids stale pane-id collisions after a pane is closed and reopened.
Diffstat (limited to 'zellij-server/src')
-rw-r--r--zellij-server/src/os_input_output_windows.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/zellij-server/src/os_input_output_windows.rs b/zellij-server/src/os_input_output_windows.rs
index f3cb2266..a3defae9 100644
--- a/zellij-server/src/os_input_output_windows.rs
+++ b/zellij-server/src/os_input_output_windows.rs
@@ -2,13 +2,13 @@ use crate::os_input_output::{resolve_command, AsyncReader};
use crate::panes::PaneId;
use std::{
- collections::{BTreeMap, BTreeSet},
+ collections::BTreeMap,
ffi::OsStr,
io,
os::windows::ffi::OsStrExt,
os::windows::io::{FromRawHandle, IntoRawHandle, OwnedHandle},
sync::{
- atomic::{AtomicU64, Ordering},
+ atomic::{AtomicU32, AtomicU64, Ordering},
Arc, Mutex,
},
};
@@ -370,12 +370,14 @@ fn terminate_process(pid: u32) -> std::result::Result<(), std::io::Error> {
#[derive(Clone)]
pub(crate) struct WindowsPtyBackend {
terminals: Arc<Mutex<BTreeMap<u32, Option<ConPtyTerminal>>>>,
+ next_terminal_id_counter: Arc<AtomicU32>,
}
impl WindowsPtyBackend {
pub fn new() -> Result<Self, io::Error> {
Ok(Self {
terminals: Arc::new(Mutex::new(BTreeMap::new())),
+ next_terminal_id_counter: Arc::new(AtomicU32::new(0)),
})
}
@@ -634,14 +636,9 @@ impl WindowsPtyBackend {
}
pub fn next_terminal_id(&self) -> Option<u32> {
- self.terminals
- .lock()
- .unwrap()
- .keys()
- .copied()
- .collect::<BTreeSet<u32>>()
- .last()
- .map(|l| l + 1)
- .or(Some(0))
+ Some(
+ self.next_terminal_id_counter
+ .fetch_add(1, Ordering::Relaxed),
+ )
}
}