Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

^[[O and ^[[I being sent to active tmux window, even if not the one with vim running #2

Open
mydimension opened this issue Apr 13, 2012 · 11 comments

Comments

@mydimension
Copy link

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.

@sjl
Copy link
Owner

sjl commented Apr 13, 2012

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?

@aaronjensen
Copy link
Contributor

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

@sjl
Copy link
Owner

sjl commented Aug 16, 2012

@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.

@sjl
Copy link
Owner

sjl commented Aug 16, 2012

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.

@rstacruz
Copy link

One workaround is to use:

let g:vitality_fix_focus=0

You'll lose the FocusLost/FocusGained functionality, however.

@akracun
Copy link

akracun commented Jan 20, 2013

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.

@aaronjensen
Copy link
Contributor

@akracun awesome. Any chance of this making it into tmux mainline?

@aaronjensen
Copy link
Contributor

@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.

@aaronjensen
Copy link
Contributor

I'm using this for now:

[ -n "$TMUX" ] && tmux set-option -g focus-filter on > /dev/null 2>&1 && export TMUX_CAN_FOCUS=1

@akracun
Copy link

akracun commented Feb 18, 2013

@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.

@bruno-
Copy link

bruno- commented Dec 13, 2014

Good news everyone, it seems the tmux issue/request referenced in this post is now implemented in tmux!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants