Tidy up error messages from split-window.

This commit is contained in:
nicm
2026-06-13 18:30:16 +00:00
parent 654758e622
commit b182791052
2 changed files with 22 additions and 9 deletions

View File

@@ -120,7 +120,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
else else
lc = layout_get_tiled_cell(item, args, w, wp, flags, &cause); lc = layout_get_tiled_cell(item, args, w, wp, flags, &cause);
if (cause != NULL) { if (cause != NULL) {
cmdq_error(item, "size or position %s", cause); cmdq_error(item, "%s", cause);
free(cause); free(cause);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }

View File

@@ -1416,31 +1416,44 @@ layout_get_floating_cell(struct cmdq_item *item, struct args *args,
struct layout_cell *lcnew; struct layout_cell *lcnew;
int sx = w->sx / 2, sy = w->sy / 4; int sx = w->sx / 2, sy = w->sy / 4;
int ox = INT_MAX, oy = INT_MAX; int ox = INT_MAX, oy = INT_MAX;
char *error;
if (args_has(args, 'x')) { if (args_has(args, 'x')) {
sx = args_percentage_and_expand(args, 'x', 0, w->sx - 1, w->sx, sx = args_percentage_and_expand(args, 'x', 0, w->sx - 1, w->sx,
item, cause); item, &error);
if (*cause != NULL) if (error != NULL) {
xasprintf(cause, "position %s", error);
free(error);
return (NULL); return (NULL);
} }
}
if (args_has(args, 'y')) { if (args_has(args, 'y')) {
sy = args_percentage_and_expand(args, 'y', 0, w->sy - 1, w->sy, sy = args_percentage_and_expand(args, 'y', 0, w->sy - 1, w->sy,
item, cause); item, &error);
if (*cause != NULL) if (error != NULL) {
xasprintf(cause, "position %s", error);
free(error);
return (NULL); return (NULL);
} }
}
if (args_has(args, 'X')) { if (args_has(args, 'X')) {
ox = args_percentage_and_expand(args, 'X', -sx, w->sx, ox = args_percentage_and_expand(args, 'X', -sx, w->sx,
w->sx, item, cause); w->sx, item, &error);
if (*cause != NULL) if (error != NULL) {
xasprintf(cause, "size %s", error);
free(error);
return (NULL); return (NULL);
} }
}
if (args_has(args, 'Y')) { if (args_has(args, 'Y')) {
oy = args_percentage_and_expand(args, 'Y', -sy, w->sy, oy = args_percentage_and_expand(args, 'Y', -sy, w->sy,
w->sy, item, cause); w->sy, item, &error);
if (*cause != NULL) if (error != NULL) {
xasprintf(cause, "size %s", error);
free(error);
return (NULL); return (NULL);
} }
}
if (ox == INT_MAX) { if (ox == INT_MAX) {
if (w->last_new_pane_x == 0) if (w->last_new_pane_x == 0)