Project and Repair workspaces; adoption keeps the person's own pane; truncation fix
This commit is contained in:
@@ -100,19 +100,24 @@ def open_pane(name, workspace_name, cwd, command, session=None, adopt_existing=F
|
||||
the pane that keeps the workspace alive.
|
||||
"""
|
||||
ws = claim(workspace_name, session)
|
||||
# A pane that was already in this workspace before us is the one to keep:
|
||||
# it is the person's own shell, and it is what stops the workspace being
|
||||
# deleted. Only when the workspace is empty do we make a new one, and only
|
||||
# then does a name match matter.
|
||||
if adopt_existing:
|
||||
existing = [w for w in windows(session) if w.get("workspace") == ws]
|
||||
if existing:
|
||||
w = existing[0]
|
||||
if (w.get("custom_name") or "") != name:
|
||||
subprocess.run(
|
||||
["tuios", "set-window", "-w", w["window_id"], "--name", name,
|
||||
"-s", session or SESSION],
|
||||
capture_output=True, text=True, timeout=30, check=False,
|
||||
)
|
||||
return "adopted", w["window_id"], ws
|
||||
for w in windows(session):
|
||||
if (w.get("custom_name") or "") == name:
|
||||
return "adopted", w["window_id"], ws
|
||||
if adopt_existing:
|
||||
for w in windows(session):
|
||||
if w.get("workspace") == ws:
|
||||
if not (w.get("custom_name") or ""):
|
||||
subprocess.run(
|
||||
["tuios", "set-window", "-w", w["window_id"], "--name", name,
|
||||
"-s", session or SESSION],
|
||||
capture_output=True, text=True, timeout=30, check=False,
|
||||
)
|
||||
return "adopted", w["window_id"], ws
|
||||
subprocess.run(
|
||||
[
|
||||
"tuios", "new-window", name,
|
||||
|
||||
Reference in New Issue
Block a user