summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2022-03-08 22:14:25 +0000
committernicm <nicm>2022-03-08 22:14:25 +0000
commitbfbe972225d10be7f6eaca22d88d90df4fae09c9 (patch)
treed517d66edba2ad709489db4b29aa1c7efcbd2f7b
parentcf217fa6181013bb70f77d6a50565e086205c5f4 (diff)
With -f use percentages of window size not pane size, GitHub issue 2866.
-rw-r--r--cmd-split-window.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 0f82e648..4c8054ec 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -61,6 +61,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
struct client *tc = cmdq_get_target_client(item);
struct session *s = target->s;
struct winlink *wl = target->wl;
+ struct window *w = wl->window;
struct window_pane *wp = target->wp, *new_wp;
enum layout_type type;
struct layout_cell *lc;
@@ -87,10 +88,17 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "percentage %s", errstr);
return (CMD_RETURN_ERROR);
}
- if (type == LAYOUT_TOPBOTTOM)
- size = (wp->sy * percentage) / 100;
- else
- size = (wp->sx * percentage) / 100;
+ if (args_has(args, 'f')) {
+ if (type == LAYOUT_TOPBOTTOM)
+ size = (w->sy * percentage) / 100;
+ else
+ size = (w->sx * percentage) / 100;
+ } else {
+ if (type == LAYOUT_TOPBOTTOM)
+ size = (wp->sy * percentage) / 100;
+ else
+ size = (wp->sx * percentage) / 100;
+ }
} else {
size = args_strtonum(args, 'l', 0, INT_MAX, &cause);
if (cause != NULL) {
@@ -106,10 +114,17 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
free(cause);
return (CMD_RETURN_ERROR);
}
- if (type == LAYOUT_TOPBOTTOM)
- size = (wp->sy * percentage) / 100;
- else
- size = (wp->sx * percentage) / 100;
+ if (args_has(args, 'f')) {
+ if (type == LAYOUT_TOPBOTTOM)
+ size = (w->sy * percentage) / 100;
+ else
+ size = (w->sx * percentage) / 100;
+ } else {
+ if (type == LAYOUT_TOPBOTTOM)
+ size = (wp->sy * percentage) / 100;
+ else
+ size = (wp->sx * percentage) / 100;
+ }
} else
size = -1;