Open mydimension opened 12 years ago
You're right. I noticed this myself.
The problem is that we're telling iTerm2 to report focus when we start Vim, but we really only want it to report focus when that window is the active one.
I'm not sure what the best way to fix this is.
We really need a way for Vim to get notified when its tmux pane is activated or deactivated.
Anyone have any ideas?
This isn't the solution as there are still problems with it, but you can always ignore those with your inputrc:
'\e[O': ''
'\e[I': ''
The real solution would require tmux to notify the pane when it gained or lost focus: https://sourceforge.net/tracker/index.php?func=detail&aid=3558288&group_id=200378&atid=973265
@aaronjensen is correct. If you use Fish like me, you'll need to use bind
to bind those sequences to a noop instead:
bind \e\[O true
bind \e\[I true
I'll leave this open in case tmux ever implements the notifications.
Note that this only fixes things in the shell. Once control passes to another program you'll still get the stray characters. The real solution is, as @aaronjensen mentioned, for tmux to allow notification to panes.
One workaround is to use:
let g:vitality_fix_focus=0
You'll lose the FocusLost/FocusGained functionality, however.
I have a version of tmux that handles this issue. https://github.com/akracun/tmux
You'll need to bundle it with my version of vitality.
@akracun awesome. Any chance of this making it into tmux mainline?
@akracun I'm not seeing focus-filter in tmux show-options -g
, should i? Is there some other way to find it? I'd like to be able to check for it.
I'm using this for now:
[ -n "$TMUX" ] && tmux set-option -g focus-filter on > /dev/null 2>&1 && export TMUX_CAN_FOCUS=1
@aaronjensen focus-filter is a window option, use tmux show-options -wg focus-filter
to inspect its value.
I'll add this option check in to my vitality.vim repository.
As for adding this feature to tmux mainline, I'll look into it.
Good news everyone, it seems the tmux issue/request referenced in this post is now implemented in tmux!
Say I have 2 tmux windows (0:0 and 0:1) and vim is running in one of them (0:0). I have focused the window that does not have vim running (0:1). If i leave iterm2 the escape sequence ^[[O is sent to window 0:1 and causes a newline to appear after the prompt and rings a bell in iterm2. returning focus to iterm2 also sends the escape sequence ^[[I but no visual disturbance occurs.