skip existing named windows on tmuxp load -a workspace
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start by reading tmuxp/workspace/builder.py around WorkspaceBuilder's window creation logic and compare the requested behavior with the supplied patch. Determine how the behavior should be enabled and what should happen for named versus unnamed windows. Done means rerunning tmuxp load -a workspace does not recreate existing named windows while still recreating a closed named window.
Written by the indexing model from the issue text.
Description
Step 1: Provide a summary of your problem
tmuxp load -a workspaceduplicates existing windows in a session, when called a second time inside tmux
Step 2: Provide tmuxp details
tmux version: 3.3
libtmux version: 0.21.0
tmuxp version: 1.27.0
Step 3: Describe the problem:
Running tmuxp load -a workspace inside tmux duplicates existing windows in a session - it would be nice if existing named windows are not recreated.
So - closing a tmux window, updating the tmuxp workspace config file and rerunning tmuxp load -a workspace should recreate the closed window only (if all windows are named)
Steps to reproduce:
Run tmuxp load -a workspace inside tmux a second time - windows are duplicated
Relevant Code:
The following patch to tmuxp/workspace/builder.py skips existing named windows - but I'm new to tmuxp - a option for enabling this behavior would be necessary - and I don't know, if this is even the correct place for this patch.
--- builder.py.orig 2023-03-16 12:59:43.399597590 +0100
+++ builder.py 2023-03-21 20:46:05.998656705 +0100
@@ -346,6 +346,8 @@ class WorkspaceBuilder:
Newly created window, and the section from the tmuxp configuration
that was used to create the window.
"""
+ session_window_names = set([w.window_name for w in session.windows if w.window_name])
+
for window_iterator, window_config in enumerate(
self.session_config["windows"], start=1
):
@@ -353,6 +355,9 @@ class WorkspaceBuilder:
window_name = None
else:
window_name = window_config["window_name"]
+ if window_name in session_window_names:
+ # skip existing window
+ continue
is_first_window_pass = self.first_window_pass(
window_iterator, session, append
Thanks,
Gerald
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 248
- Avg merge
- 2h 13m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tmux-python/tmuxp
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
tmux-python/tmuxp#1026 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
tmux-python/tmuxp#939 · 1 comment ·
-
enhancement WorkspaceBuilder
Difficulty 4/5 3-5 days Newbie friendliness 48/100
tmux-python/tmuxp#1062 ·
-
enhancement need-comments WorkspaceBuilder
Difficulty 5/5 Over a week Newbie friendliness 35/100
tmux-python/tmuxp#1058 · 2 comments ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
tmux-python/tmuxp#1053 · 10 comments ·
All issues in tmux-python/tmuxp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100