rebuild pane width/height using splits to prevent word wrapping glitch

Fixes #44.

The initial idea was to use window force-width/height option to use
current pane size when initilizing fingers pane, but for reasons unknown
it does not work.

No idea why it works with splits, but it doesn't with force-width/height
options. Welcome to tmux-fingers.
This commit is contained in:
Jorge Morante 2018-01-29 23:03:41 +01:00
parent 9089bf26a1
commit a3ea072959
4 changed files with 28 additions and 10 deletions

View File

@ -14,8 +14,9 @@ tmux_yank_copy_command=$(tmux_list_vi_copy_keys | grep -E "(vi-copy|copy-mode-vi
current_pane_id=$1 current_pane_id=$1
fingers_pane_id=$2 fingers_pane_id=$2
pane_input_temp=$3 fingers_window_id=$2
original_rename_setting=$4 pane_input_temp=$4
original_rename_setting=$5
BACKSPACE=$'\177' BACKSPACE=$'\177'
@ -41,7 +42,7 @@ function zoom_pane() {
function handle_exit() { function handle_exit() {
tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id" tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id"
[[ $pane_was_zoomed == "1" ]] && zoom_pane "$current_pane_id" [[ $pane_was_zoomed == "1" ]] && zoom_pane "$current_pane_id"
tmux kill-pane -t "$fingers_pane_id" tmux kill-window -t "$fingers_window_id"
tmux set-window-option automatic-rename "$original_rename_setting" tmux set-window-option automatic-rename "$original_rename_setting"
rm -rf "$pane_input_temp" "$pane_output_temp" "$match_lookup_table" rm -rf "$pane_input_temp" "$pane_output_temp" "$match_lookup_table"
} }
@ -175,7 +176,7 @@ while read -rsn1 char; do
copy_result "$result" copy_result "$result"
revert_to_original_pane "$current_pane_id" "$fingers_pane_id" revert_to_original_pane "$current_pane_id" "$fingers_pane_id" "$fingers_window_id"
exit 0 exit 0
done < /dev/tty done < /dev/tty

View File

@ -37,6 +37,6 @@ function show_hints_and_swap() {
current_pane_id=$1 current_pane_id=$1
fingers_pane_id=$2 fingers_pane_id=$2
compact_state=$3 compact_state=$3
show_hints "$fingers_pane_id" $compact_state show_hints "$fingers_pane_id" "$compact_state"
tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id" tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id"
} }

View File

@ -4,8 +4,22 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $CURRENT_DIR/utils.sh source $CURRENT_DIR/utils.sh
function init_fingers_pane() { function init_fingers_pane() {
local pane_id=$(tmux new-window -F "#{pane_id}" -P -d -n "[fingers]" "$(init_pane_cmd)") local fingers_ids=$(tmux new-window -F "#{pane_id}:#{window_id}" -P -d -n "[fingers]" "$(init_pane_cmd)")
echo $pane_id local fingers_pane_id=$(echo "$fingers_ids" | cut -f1 -d:)
local fingers_window_id=$(echo "$fingers_ids" | cut -f2 -d:)
local current_size=$(tmux list-panes -F "#{pane_width}:#{pane_height}:#{?pane_active,active,nope}" | grep active)
local current_width=$(echo "$current_size" | cut -f1 -d:)
local current_height=$(echo "$current_size" | cut -f2 -d:)
local current_window_size=$(tmux list-windows -F "#{window_width}:#{window_height}:#{?window_active,active,nope}" | grep active)
local current_window_width=$(echo "$current_window_size" | cut -f1 -d:)
local current_window_height=$(echo "$current_window_size" | cut -f2 -d:)
tmux split-window -d -t "$fingers_pane_id" -h -l "$(expr "$current_window_width" - "$current_width" - 1)" '/bin/nop'
tmux split-window -d -t "$fingers_pane_id" -l "$(expr "$current_window_height" - "$current_height" - 1)" '/bin/nop'
echo "$fingers_pane_id:$fingers_window_id"
} }
function capture_pane() { function capture_pane() {
@ -32,7 +46,9 @@ function capture_pane() {
function prompt_fingers_for_pane() { function prompt_fingers_for_pane() {
local current_pane_id=$1 local current_pane_id=$1
local fingers_pane_id=$(init_fingers_pane) local fingers_init_data=$(init_fingers_pane)
local fingers_pane_id=$(echo "$fingers_init_data" | cut -f1 -d':')
local fingers_window_id=$(echo "$fingers_init_data" | cut -f2 -d':')
local tmp_path=$(fingers_tmp) local tmp_path=$(fingers_tmp)
wait wait
@ -41,7 +57,7 @@ function prompt_fingers_for_pane() {
local original_rename_setting=$(tmux show-window-option -gv automatic-rename) local original_rename_setting=$(tmux show-window-option -gv automatic-rename)
tmux set-window-option automatic-rename off tmux set-window-option automatic-rename off
pane_exec "$fingers_pane_id" "cat $tmp_path | $CURRENT_DIR/fingers.sh \"$current_pane_id\" \"$fingers_pane_id\" $tmp_path $original_rename_setting" pane_exec "$fingers_pane_id" "cat $tmp_path | $CURRENT_DIR/fingers.sh \"$current_pane_id\" \"$fingers_pane_id\" \"$fingers_window_id\" $tmp_path $original_rename_setting"
echo $fingers_pane_id echo $fingers_pane_id
} }

View File

@ -69,8 +69,9 @@ function display_message() {
function revert_to_original_pane() { function revert_to_original_pane() {
local current_pane_id=$1 local current_pane_id=$1
local fingers_pane_id=$2 local fingers_pane_id=$2
local fingers_window_id=$3
tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id" tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id"
tmux kill-pane -t "$fingers_pane_id" tmux kill-window -t "$fingers_window_id"
} }
function pane_exec() { function pane_exec() {