We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7e78f22 commit 6327455Copy full SHA for 6327455
1 file changed
src/session.rs
@@ -48,9 +48,20 @@ impl Session {
48
true
49
}
50
51
- /// Unsets the terminal for this session, returning the previous terminal if it existed.
52
- pub fn unset_terminal(&self) -> Option<Arc<dyn Any + Send + Sync>> {
53
- self.terminal.lock().take()
+ /// Unsets the terminal for this session if it is the given terminal.
+ pub fn unset_terminal(&self, term: &Arc<dyn Any + Send + Sync>) -> bool {
+ let mut guard = self.terminal.lock();
54
+ if guard.as_ref().is_some_and(|it| Arc::ptr_eq(it, term)) {
55
+ *guard = None;
56
+ true
57
+ } else {
58
+ false
59
+ }
60
61
+
62
+ /// Gets the terminal for this session, if it exists.
63
+ pub fn terminal(&self) -> Option<Arc<dyn Any + Send + Sync>> {
64
+ self.terminal.lock().clone()
65
66
67
0 commit comments