Try this please which changes the error messages:
Index: cmd-select-layout.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/cmd-select-layout.c,v
retrieving revision 1.40
diff -u -p -r1.40 cmd-select-layout.c
--- cmd-select-layout.c 21 Aug 2021 10:22:39 -0000 1.40
+++ cmd-select-layout.c 5 Apr 2022 10:58:00 -0000
@@ -77,7 +77,7 @@ cmd_select_layout_exec(struct cmd *self,
struct window *w = wl->window;
struct window_pane *wp = target->wp;
const char *layoutname;
- char *oldlayout;
+ char *oldlayout, *cause;
int next, previous, layout;
server_unzoom_window(w);
@@ -124,8 +124,9 @@ cmd_select_layout_exec(struct cmd *self,
}
if (layoutname != NULL) {
- if (layout_parse(w, layoutname) == -1) {
- cmdq_error(item, "can't set layout: %s", layoutname);
+ if (layout_parse(w, layoutname, &cause) == -1) {
+ cmdq_error(item, "%s: %s", cause, layoutname);
+ free(cause);
goto error;
}
goto changed;
Index: layout-custom.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/layout-custom.c,v
retrieving revision 1.20
diff -u -p -r1.20 layout-custom.c
--- layout-custom.c 11 Mar 2021 06:31:05 -0000 1.20
+++ layout-custom.c 5 Apr 2022 10:58:01 -0000
@@ -154,7 +154,7 @@ layout_check(struct layout_cell *lc)
/* Parse a layout string and arrange window as layout. */
int
-layout_parse(struct window *w, const char *layout)
+layout_parse(struct window *w, const char *layout, char **cause)
{
struct layout_cell *lc, *lcchild;
struct window_pane *wp;
@@ -165,22 +165,30 @@ layout_parse(struct window *w, const cha
if (sscanf(layout, "%hx,", &csum) != 1)
return (-1);
layout += 5;
- if (csum != layout_checksum(layout))
+ if (csum != layout_checksum(layout)) {
+ *cause = xstrdup("invalid layout");
return (-1);
+ }
/* Build the layout. */
lc = layout_construct(NULL, &layout);
- if (lc == NULL)
+ if (lc == NULL) {
+ *cause = xstrdup("invalid layout");
return (-1);
- if (*layout != '\0')
+ }
+ if (*layout != '\0') {
+ *cause = xstrdup("invalid layout");
goto fail;
+ }
/* Check this window will fit into the layout. */
for (;;) {
npanes = window_count_panes(w);
ncells = layout_count_cells(lc);
- if (npanes > ncells)
+ if (npanes > ncells) {
+ xasprintf(cause, "too many panes (need %u)", ncells);
goto fail;
+ }
if (npanes == ncells)
break;
@@ -217,8 +225,10 @@ layout_parse(struct window *w, const cha
}
/* Check the new layout. */
- if (!layout_check(lc))
+ if (!layout_check(lc)) {
+ *cause = xstrdup("size mismatch after applying layout");
return (-1);
+ }
/* Resize to the layout size. */
window_resize(w, lc->sx, lc->sy, -1, -1);
Index: tmux.h
===================================================================
RCS file: /cvs/src/usr.bin/tmux/tmux.h,v
retrieving revision 1.1166
diff -u -p -r1.1166 tmux.h
--- tmux.h 24 Mar 2022 09:05:57 -0000 1.1166
+++ tmux.h 5 Apr 2022 10:58:01 -0000
@@ -3017,7 +3017,7 @@ void layout_spread_out(struct window_p
/* layout-custom.c */
char *layout_dump(struct layout_cell *);
-int layout_parse(struct window *, const char *);
+int layout_parse(struct window *, const char *, char **);
/* layout-set.c */
int layout_set_lookup(const char *);