mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-12-23 07:18:57 +00:00
parent
9a6e4a1a2c
commit
f9ef86d604
@ -5,6 +5,8 @@
|
||||
issues during the restore and is now fixed.
|
||||
- restoring sessions multiple times messes up the whole environment - new panes
|
||||
are all around. This is now fixed - pane restorations are now idempotent.
|
||||
- if pane exists from before session restore - do not restore the process within
|
||||
it. This makes the restoration process even more idempotent.
|
||||
|
||||
### v0.2.0, 2014-08-29
|
||||
- bugfix: with vim 'session' strategy, if the session file does not exist - make
|
||||
|
@ -13,7 +13,7 @@ restore_pane_process() {
|
||||
local window_number="$3"
|
||||
local pane_index="$4"
|
||||
local dir="$5"
|
||||
if _process_should_be_restored "$pane_full_command"; then
|
||||
if _process_should_be_restored "$pane_full_command" "$session_name" "$window_number" "$pane_index"; then
|
||||
tmux switch-client -t "${session_name}:${window_number}"
|
||||
tmux select-pane -t "$pane_index"
|
||||
|
||||
@ -32,7 +32,14 @@ restore_pane_process() {
|
||||
|
||||
_process_should_be_restored() {
|
||||
local pane_full_command="$1"
|
||||
if _restore_all_processes; then
|
||||
local session_name="$2"
|
||||
local window_number="$3"
|
||||
local pane_index="$4"
|
||||
if is_pane_registered_as_existing "$session_name" "$window_number" "$pane_index"; then
|
||||
# Scenario where pane existed before restoration, so we're not
|
||||
# restoring the proces either.
|
||||
return 1
|
||||
elif _restore_all_processes; then
|
||||
return 0
|
||||
elif _process_on_the_restore_list "$pane_full_command"; then
|
||||
return 0
|
||||
|
@ -7,6 +7,12 @@ source "$CURRENT_DIR/helpers.sh"
|
||||
source "$CURRENT_DIR/process_restore_helpers.sh"
|
||||
source "$CURRENT_DIR/spinner_helpers.sh"
|
||||
|
||||
# Global variable.
|
||||
# Used during the restoration: if a pane already exists from before, it is
|
||||
# saved in the array in this variable. Later, process running in existing pane
|
||||
# is also not restored. That makes the restoration process more idempotent.
|
||||
EXISTING_PANES_VAR=""
|
||||
|
||||
is_line_type() {
|
||||
local line_type="$1"
|
||||
local line="$2"
|
||||
@ -30,6 +36,23 @@ pane_exists() {
|
||||
\grep -q "^$pane_index$"
|
||||
}
|
||||
|
||||
register_existing_pane() {
|
||||
local session_name="$1"
|
||||
local window_number="$2"
|
||||
local pane_index="$3"
|
||||
local pane_custom_id="${session_name}:${window_number}:${pane_index}"
|
||||
local delimiter=$'\t'
|
||||
EXISTING_PANES_VAR="${EXISTING_PANES_VAR}${delimiter}${pane_custom_id}"
|
||||
}
|
||||
|
||||
is_pane_registered_as_existing() {
|
||||
local session_name="$1"
|
||||
local window_number="$2"
|
||||
local pane_index="$3"
|
||||
local pane_custom_id="${session_name}:${window_number}:${pane_index}"
|
||||
[[ "$EXISTING_PANES_VAR" =~ "$pane_custom_id" ]]
|
||||
}
|
||||
|
||||
window_exists() {
|
||||
local session_name="$1"
|
||||
local window_number="$2"
|
||||
@ -81,13 +104,14 @@ new_pane() {
|
||||
|
||||
restore_pane() {
|
||||
local pane="$1"
|
||||
echo "$pane" |
|
||||
while IFS=$'\t' read line_type session_name window_number window_name window_active window_flags pane_index dir pane_active pane_command pane_full_command; do
|
||||
dir="$(remove_first_char "$dir")"
|
||||
window_name="$(remove_first_char "$window_name")"
|
||||
pane_full_command="$(remove_first_char "$pane_full_command")"
|
||||
if pane_exists "$session_name" "$window_number" "$pane_index"; then
|
||||
true # pane exists, no need to create it!
|
||||
# Pane exists, no need to create it!
|
||||
# Pane existence is registered. Later, it's process also isn't restored.
|
||||
register_existing_pane "$session_name" "$window_number" "$pane_index"
|
||||
elif window_exists "$session_name" "$window_number"; then
|
||||
new_pane "$session_name" "$window_number" "$window_name" "$dir"
|
||||
elif session_exists "$session_name"; then
|
||||
@ -95,7 +119,7 @@ restore_pane() {
|
||||
else
|
||||
new_session "$session_name" "$window_number" "$window_name" "$dir"
|
||||
fi
|
||||
done
|
||||
done < <(echo "$pane")
|
||||
}
|
||||
|
||||
restore_state() {
|
||||
|
Loading…
Reference in New Issue
Block a user