Expand formats in window and session names.

This commit is contained in:
nicm
2018-03-01 12:53:08 +00:00
parent 508e2f0b3a
commit 182357f24b
5 changed files with 70 additions and 50 deletions

View File

@ -61,8 +61,8 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
struct window *w = wl->window;
struct window_pane *wp = item->target.wp, *new_wp = NULL;
struct environ *env;
const char *cmd, *path, *shell, *template, *cwd;
char **argv, *cause, *new_cause, *cp, *to_free = NULL;
const char *cmd, *path, *shell, *template, *tmp;
char **argv, *cause, *new_cause, *cp, *cwd;
u_int hlimit;
int argc, size, percentage;
enum layout_type type;
@ -86,14 +86,12 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
argv = args->argv;
}
if (args_has(args, 'c')) {
cwd = args_get(args, 'c');
to_free = format_single(item, cwd, c, s, NULL, NULL);
cwd = to_free;
} else if (item->client != NULL && item->client->session == NULL)
cwd = item->client->cwd;
if ((tmp = args_get(args, 'c')) != NULL)
cwd = format_single(item, tmp, c, s, NULL, NULL);
else if (item->client != NULL && item->client->session == NULL)
cwd = xstrdup(item->client->cwd);
else
cwd = s->cwd;
cwd = xstrdup(s->cwd);
type = LAYOUT_TOPBOTTOM;
if (args_has(args, 'h'))
@ -175,7 +173,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
cmd_find_from_winlink_pane(&fs, wl, new_wp, 0);
hooks_insert(s->hooks, item, &fs, "after-split-window");
free(to_free);
free(cwd);
return (CMD_RETURN_NORMAL);
error:
@ -186,6 +184,6 @@ error:
cmdq_error(item, "create pane failed: %s", cause);
free(cause);
free(to_free);
free(cwd);
return (CMD_RETURN_ERROR);
}