Skip to content

Commit

Permalink
plugin/magit.vim: simplify auto jump to magit window if any
Browse files Browse the repository at this point in the history
  • Loading branch information
jreybert committed Feb 1, 2017
1 parent 2ead05a commit f5756b2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ function! magit#toggle_help()
call magit#update_buffer()
endfunction

let g:magit_windows = {}
" magit#show_magit: prepare and show magit buffer
" it also set local mappings to magit buffer
" param[in] display:
Expand Down Expand Up @@ -810,7 +811,8 @@ function! magit#show_magit(display, ...)

let buffer_name=fnameescape('magit://' . git_dir)

let magit_win = magit#utils#search_buffer_in_windows(buffer_name)
let magit_win = has_key(g:magit_windows, buffer_name) ?
\ g:magit_windows[buffer_name] : 0

if ( magit_win != 0 )
silent execute magit_win."wincmd w"
Expand All @@ -830,6 +832,7 @@ function! magit#show_magit(display, ...)
else
throw 'parameter_error'
endif
let g:magit_windows[buffer_name] = winnr()

silent execute "buffer " . buffer_name

Expand Down

0 comments on commit f5756b2

Please sign in to comment.