IngoMeyer441 / tmux-easy-motion

Vim's easy-motion for tmux
MIT License
81 stars 6 forks source link

Not working - Error with reading cursor position #13

Closed mikh3x4 closed 3 years ago

mikh3x4 commented 3 years ago

Hi,

I'm a big fan of the vim version of this plugin so I'd love to be able to use it in tmux. Unfortunately I'm running into a bug. When I try triggering the plugin I get this error message on the status bar.

Error: The cursor position ":" is not in the format "<row>:<col>".

A new window opens with the following command:

/afs/.ir/users/m/i/mikadam/.tmux/plugins/tmux-easy-motion/scripts/easy_motion.py "fg=colour242" "fg=colour196,bold" "fg=brightyellow,bold" "fg=yellow,bold" "w" "" "asdghklqwertyuiopzxcvbnmfj;" ":" "211:47" "/tmp/tmp.oHlM3fU4Xz/capture.out" "/tmp/tmp.oHlM3fU4Xz/jump.pipe" "/tmp/tmux-easy-motion-target-key-pipe_mikadam_95726/1/target_key.pipe"

I've done a bit of digging and determined the issue is with the ":" argument to the python script. I think it should contain the current x and y position of the cursor. Its supposed to get generated using the read_cursor_position shell function which in turn uses the tmux display-message -p -t "${pane_id}" "#{${cursor_type}_y}:#{${cursor_type}_x}" command.

If I run the display-message -p "2" "#{cursor_y}:#{cursor_x}" command manually it gives back the correct cursor position. In the easy_motion_setup function in easy_motion.sh its already incorrect.

For reference here is my minimal .tmux.conf

# autoinstall plugins
if "test ! -d ~/.tmux/plugins/tpm" \
   "run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"

set-option -g  prefix C-s

bind-key V next-layout
bind-key -T copy-mode-vi v send-keys -X begin-selection

set -g @plugin 'tmux-plugins/tpm'

set -g @plugin 'IngoMeyer441/tmux-easy-motion'
set -g @easy-motion-prefix "Space"
set -g @easy-motion-default-motion "bd-w"

run '~/.tmux/plugins/tpm/tpm'

My tmux version is 3.0a

mikh3x4 commented 3 years ago

Also I keep getting zombie processes of the form

sh -c /afs/.ir/users/m/i/mikadam/.tmux/plugins/tmux-easy-motion/scripts/easy_motion.sh '95726' '$1' '@3' '%3' 'bd-w' and bash /afs/.ir/users/m/i/mikadam/.tmux/plugins/tmux-easy-motion/scripts/easy_motion.sh 95726 $1 @3 %3 bd-w

I'll try poking around a bit more and will post updates if I have any

mikh3x4 commented 3 years ago

Looks like the copy_cursor_x and copy_cursor_y variables were added in tmux 3.1 not 3.0. See the change log

I also think on my system the is_pane_in_copy_mode always says its in copy mode

IngoMeyer441 commented 3 years ago

Hey and thanks for giving my plugin a try! :slightly_smiling_face: I compiled tmux 3.0a on a fresh Ubuntu 20.04 and I can confirm the bug. But are you sure that copy_cursor_x and copy_cursor_y were not available before tmux 3.1?

mikh3x4 commented 3 years ago

I’m actually very excited about this plugin :) Thanks for writing it

I’m just going off the change log I linked above. I also tracked down the commit where I think tmux added them and it’s labelled for merge in 3.1a

IngoMeyer441 commented 3 years ago

OK sorry, I missed it in the Changelog. Currently, I am not at my computer but I can try to find a fix in the next days. Is it maybe an option for you to upgrade to tmux 3.1?

IngoMeyer441 commented 3 years ago

I double checked and you are right, commit 56e5067c introduced copy_cursor_x and copy_cursor_y and was included in tmux 3.1 (the a version is not necessary). The problem is that this plugin cannot work without knowing the cursor position in copy mode. Maybe it is possible to get the cursor position with an ANSI escape code instead. The easiest solution would be to increase the version requirement of this plugin from tmux 3.0 to 3.1. Are you stuck at version 3.0a for any reason?

IngoMeyer441 commented 3 years ago

I first fix the tmux version requirement. If we find a fix for tmux < 3.1 I can still set a lower version requirement.

mikh3x4 commented 3 years ago

Unfortunately this is on a remote server so I don't have sudo privileges. I tried running tmux's new version as an appimage but it was quite slow for some reason. I think it will be easiest if I just ask our admin to upgrade to the new version.

Thanks for responding so quickly to this. I'm looking forward to using the plugin once I have the new tmux version :)

IngoMeyer441 commented 3 years ago

Great :smiley: I am also a big fan of vim easy motion and use it every day, so I hope, you enjoy it and it fits your needs. Feel free to reopen if you cannot use a newer tmux version and please let me know if you miss anything.

IngoMeyer441 commented 3 years ago

If you only want to use tmux with your user account, it could also be an option to build tmux from source and place it in your home directory:

curl -O -L "https://github.com/tmux/tmux/releases/download/3.2/tmux-3.2.tar.gz"
tar -xvf tmux-3.2.tar.gz
cd tmux-3.2
./configure --prefix="${HOME}/local"
make
make install

Afterwards, add ${HOME}/local/bin to your PATH

export PATH="${HOME}/local/bin:${PATH}"

and you are ready to use the latest tmux version.