mirror of
https://github.com/tmux/tmux.git
synced 2024-11-16 17:39:09 +00:00
Make an empty state on error rather than leaving something partially
created (which now is now a fatal() later).
This commit is contained in:
parent
c83feeb6f8
commit
382e09bed1
25
cmd.c
25
cmd.c
@ -451,8 +451,11 @@ cmd_prepare_state_flag(char c, const char *target, enum cmd_entry_flag flag,
|
|||||||
log_debug("%s: flag %c %d %#x", __func__, c, flag, targetflags);
|
log_debug("%s: flag %c %d %#x", __func__, c, flag, targetflags);
|
||||||
|
|
||||||
error = cmd_find_current(¤t, item, targetflags);
|
error = cmd_find_current(¤t, item, targetflags);
|
||||||
if (error != 0 && ~targetflags & CMD_FIND_QUIET)
|
if (error != 0) {
|
||||||
return (-1);
|
if (~targetflags & CMD_FIND_QUIET)
|
||||||
|
return (-1);
|
||||||
|
cmd_find_clear_state(¤t, NULL, 0);
|
||||||
|
}
|
||||||
if (!cmd_find_empty_state(¤t) && !cmd_find_valid_state(¤t))
|
if (!cmd_find_empty_state(¤t) && !cmd_find_valid_state(¤t))
|
||||||
fatalx("invalid current state");
|
fatalx("invalid current state");
|
||||||
|
|
||||||
@ -467,8 +470,8 @@ cmd_prepare_state_flag(char c, const char *target, enum cmd_entry_flag flag,
|
|||||||
case CMD_SESSION_WITHPANE:
|
case CMD_SESSION_WITHPANE:
|
||||||
error = cmd_find_target(fs, ¤t, item, target,
|
error = cmd_find_target(fs, ¤t, item, target,
|
||||||
CMD_FIND_SESSION, targetflags);
|
CMD_FIND_SESSION, targetflags);
|
||||||
if (error != 0 && ~targetflags & CMD_FIND_QUIET)
|
if (error != 0)
|
||||||
return (-1);
|
goto error;
|
||||||
break;
|
break;
|
||||||
case CMD_MOVEW_R:
|
case CMD_MOVEW_R:
|
||||||
error = cmd_find_target(fs, ¤t, item, target,
|
error = cmd_find_target(fs, ¤t, item, target,
|
||||||
@ -482,21 +485,27 @@ cmd_prepare_state_flag(char c, const char *target, enum cmd_entry_flag flag,
|
|||||||
case CMD_WINDOW_INDEX:
|
case CMD_WINDOW_INDEX:
|
||||||
error = cmd_find_target(fs, ¤t, item, target,
|
error = cmd_find_target(fs, ¤t, item, target,
|
||||||
CMD_FIND_WINDOW, targetflags);
|
CMD_FIND_WINDOW, targetflags);
|
||||||
if (error != 0 && ~targetflags & CMD_FIND_QUIET)
|
if (error != 0)
|
||||||
return (-1);
|
goto error;
|
||||||
break;
|
break;
|
||||||
case CMD_PANE:
|
case CMD_PANE:
|
||||||
case CMD_PANE_CANFAIL:
|
case CMD_PANE_CANFAIL:
|
||||||
case CMD_PANE_MARKED:
|
case CMD_PANE_MARKED:
|
||||||
error = cmd_find_target(fs, ¤t, item, target,
|
error = cmd_find_target(fs, ¤t, item, target,
|
||||||
CMD_FIND_PANE, targetflags);
|
CMD_FIND_PANE, targetflags);
|
||||||
if (error != 0 && ~targetflags & CMD_FIND_QUIET)
|
if (error != 0)
|
||||||
return (-1);
|
goto error;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fatalx("unknown %cflag %d", c, flag);
|
fatalx("unknown %cflag %d", c, flag);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (~targetflags & CMD_FIND_QUIET)
|
||||||
|
return (-1);
|
||||||
|
cmd_find_clear_state(fs, NULL, 0);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user