aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--CHANGELOG.md1
-rw-r--r--zellij-server/src/os_input_output_windows.rs19
2 files changed, 9 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1c20fdfd..87dfd449 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* fix: idle CPU + disk i/o, CommandChanged plugin Event, GetSessionList plugin command (https://github.com/zellij-org/zellij/pull/5063)
* fix: occasional dropped characters in web client (https://github.com/zellij-org/zellij/pull/5080)
* fix: restore kitty keyboard mode on error, handle DECRPM 2026 state 3, clean up client terminal teardown sequences (https://github.com/zellij-org/zellij/pull/5058)
+* fix: stop reusing terminal pane ids on windows so reopened panes are not closed by stale events (https://github.com/zellij-org/zellij/pull/5082)
* fix: prevent occasional duplicate characters in the web client due to IME (https://github.com/zellij-org/zellij/pull/4975)
* feat: support `CSI 2031` + dark/light mode theme switching (https://github.com/zellij-org/zellij/pull/5105 and https://github.com/zellij-org/zellij/pull/5111)
* fix: incorrect interpretation of unicode characters in KKP STDIN (https://github.com/zellij-org/zellij/pull/5110)
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),
+ )
}
}