tmux-python / tmux-python/tmuxp

no space for new pane with main-horizontal and a few panes

Open
#800 33 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.6k
Forks
248
Avg merge
2h 13m
Merged PRs (30d)
1

Description

Step 1: Provide a summary of your problem

I created a yaml config with five panes in layout main-horizontal (although main-vertical also breaks). When I tried to run it it failed with the following exception:

Traceback (most recent call last):
  File "/home/abraham/.local/bin/tmuxp", line 8, in <module>
    sys.exit(cli.cli())
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/abraham/.local/lib/python3.10/site-packages/tmuxp/cli/load.py", line 573, in command_load
    load_workspace(config[-1], **tmux_options)
  File "/home/abraham/.local/lib/python3.10/site-packages/tmuxp/cli/load.py", line 418, in load_workspace
    _load_attached(builder, detached)
  File "/home/abraham/.local/lib/python3.10/site-packages/tmuxp/cli/load.py", line 159, in _load_attached
    builder.build()
  File "/home/abraham/.local/lib/python3.10/site-packages/tmuxp/workspacebuilder.py", line 268, in build
    for p, pconf in self.iter_create_panes(w, wconf):
  File "/home/abraham/.local/lib/python3.10/site-packages/tmuxp/workspacebuilder.py", line 420, in iter_create_panes
    p = w.split_window(
  File "/usr/lib/python3.10/site-packages/libtmux/window.py", line 533, in split_window
    raise exc.LibTmuxException(pane_cmd.stderr, self._info, self.panes)
libtmux.exc.LibTmuxException: (['no space for new pane'], {'session_name': 'foo', 'session_id': '$15', 'window_id': '@36', 'window_name': 'bash', 'window_width': '80', 'window_height': '24', 'window_layout': 'd96b,80x24,0,0,89', 'window_panes': '1', 'window_index': '0', 'window_flags': '*', 'window_active': '1', 'window_bell_flag': '0', 'window_activity_flag': '0', 'window_silence_flag': '0'}, [Pane(%89 Window(@36 0:bash, Session($15 foo))), Pane(%90 Window(@36 0:bash, Session($15 foo))), Pane(%91 Window(@36 0:bash, Session($15 foo))), Pane(%92 Window(@36 0:bash, Session($15 foo)))])
Step 2: Provide tmuxp details

debug-info

also my console window is 213x51

Step 3: Describe the problem:

layout is not loaded, session is partially formed but not attached, exception is thrown.

Steps to reproduce:

I created this minimal config file that reproduces the issue:

session_name: foo
windows:
- focus: 'true'
  layout: main-horizontal
  panes:
    - focus: 'true'
      shell_command:
        - echo 1
    - echo 2
    - echo 3
    - echo 4
    - echo 5
Observed Results:

A python exception

Expected Results:

A nicely built main-horizontal layout

Thoughts

Of course if I build the layout by hand it works, because I'm a human and I know that if I split the same pane over and over again, since every new pane is half the size of the previous one then soon my panes will be too small. So I resize them a little bit before splitting again, then adjust the final size.

Perhaps the algorithm for building the layout could do that. I think it is possible to know the final size of everything just from the layout, the amount of panes and the window size.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in tmuxp/workspacebuilder.py at build() and iter_create_panes(), where the failing window split is initiated; the traceback also points to cli/load.py. Reproduce the minimal five-pane main-horizontal configuration and investigate how pane creation handles available space. Done means the layout builds without a Python exception or partial session.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.