mirror of
https://github.com/danieljharvey/tmux-mate.git
synced 2024-09-11 16:46:40 +03:00
Don't attach to a session if we're already in one
This commit is contained in:
parent
21234d47fb
commit
c55c3ab264
@ -6,6 +6,7 @@ module TmuxMate.TmuxCommands
|
||||
createWindow,
|
||||
removeWindowPanes,
|
||||
removeWindows,
|
||||
attachToSession,
|
||||
getTmuxCommands,
|
||||
)
|
||||
where
|
||||
@ -41,7 +42,7 @@ getTmuxCommands sesh tmuxState =
|
||||
then removeAdminPane sTitle
|
||||
else []
|
||||
)
|
||||
<> [AttachToSession sTitle]
|
||||
<> (attachToSession sTitle runningInTmux)
|
||||
|
||||
-- create a new session if required
|
||||
createSession :: InTmuxSession -> ValidatedSession -> [VSessionName] -> [TmuxCommand]
|
||||
@ -206,3 +207,8 @@ removeWindows inTmux seshName running' windows =
|
||||
|
||||
removeAdminPane :: VSessionName -> [TmuxCommand]
|
||||
removeAdminPane seshName = pure (KillAdminPane seshName)
|
||||
|
||||
-- don't attach to session if we're in a session
|
||||
attachToSession :: VSessionName -> InTmuxSession -> [TmuxCommand]
|
||||
attachToSession _ (InTmuxSession _) = []
|
||||
attachToSession sTitle _ = [AttachToSession sTitle]
|
||||
|
@ -266,3 +266,12 @@ spec = do
|
||||
)
|
||||
]
|
||||
`shouldBe` []
|
||||
describe "Attach to session" $ do
|
||||
it "Should attach to session if we're not in one" $ do
|
||||
let sessionName' = VSessionName (NE.fromList "session")
|
||||
attachToSession sessionName' NotInTmuxSession
|
||||
`shouldBe` [AttachToSession sessionName']
|
||||
it "Should not attach to session if we're already in one" $ do
|
||||
let sessionName' = VSessionName (NE.fromList "session")
|
||||
attachToSession sessionName' (InTmuxSession sessionName')
|
||||
`shouldBe` []
|
||||
|
Loading…
Reference in New Issue
Block a user