Skip to content

Commit

Permalink
Merge pull request #24 from blueyed/fix-tmux-skipping
Browse files Browse the repository at this point in the history
Fix skipping FocusLost/FocusGained in tmux
  • Loading branch information
blueyed committed Jun 2, 2016
2 parents 84db120 + 024b737 commit 5cb27ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
@@ -1,13 +1,13 @@
language: vim

install:
- sudo add-apt-repository -y ppa:pi-rho/dev
- travis_retry sudo add-apt-repository -y ppa:pi-rho/dev
# # Not for Precise.. :/
# # - sudo add-apt-repository -y ppa:pkg-vim/vim-daily
- sudo apt-get update
# # - travis_retry sudo add-apt-repository -y ppa:pkg-vim/vim-daily
- travis_retry sudo apt-get update

- sudo apt-get install -y tmux
# - hg clone https://vim.googlecode.com/hg vim
- travis_retry sudo apt-get install -y tmux
# - travis_retry hg clone https://vim.googlecode.com/hg vim
# - ( cd vim && sudo make install )

before_script:
Expand Down
16 changes: 7 additions & 9 deletions plugin/diminactive.vim
Expand Up @@ -504,23 +504,21 @@ fun! s:Setup(...)
autocmd TabEnter * call s:Debug('EVENT: TabEnter')
\ | call s:SetupWindows()

fun! s:get_tmux_window()
return get(systemlist('tmux display -p "#{window_id}"'), 0, '')
endfun
fun! s:handle_focus_event(event) abort
if len($TMUX)
" Skip focus events on tmux when moving to or coming from another
" window.
" The tmux command for the FocusLost event will have the new
" window/pane information already.
let l:cur_tmux_win = s:get_tmux_window()
if a:event == 'FocusGained'
let s:tmux_window = l:cur_tmux_win
let cur_tmux_win = get(systemlist(
\ 'tmux display -p "#{window_id}"'), 0, '')
if a:event ==# 'FocusGained'
let s:tmux_window = cur_tmux_win
else
let s:tmux_focuslost_skipped = (l:cur_tmux_win != s:tmux_window)
let s:skip_focuslost = (cur_tmux_win != get(s:, 'tmux_window', 0))
endif
if get(s:, 'tmux_focuslost_skipped', 0)
call s:Debug('tmux: skipping '.a:event.', because of differnt window.')
if get(s:, 'skip_focuslost', 0)
call s:Debug('tmux: skipping '.a:event.', because of different window.')
return
endif
endif
Expand Down

0 comments on commit 5cb27ae

Please sign in to comment.