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

extending jump to horyzontal splits #155

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion autoload/magit/mapping.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let g:magit_commit_fixup_mapping = get(g:, 'magit_commit_fixup_mapping',
let g:magit_close_commit_mapping = get(g:, 'magit_close_commit_mapping', 'CU' )
let g:magit_reload_mapping = get(g:, 'magit_reload_mapping', 'R' )
let g:magit_edit_mapping = get(g:, 'magit_edit_mapping', 'E' )
let g:magit_edit_horyzontal_mapping= get(g:, 'magit_edit_horyzontal_mapping', 'j' )

let g:magit_jump_next_hunk = get(g:, 'magit_jump_next_hunk', '<C-N>')
let g:magit_jump_prev_hunk = get(g:, 'magit_jump_prev_hunk', '<C-P>')
Expand Down Expand Up @@ -128,7 +129,9 @@ function! magit#mapping#set_default()
call s:mg_set_mapping('n', g:magit_ignore_mapping,
\ "magit#ignore_file()", '\<\%(un\)\?staged\>')
call s:mg_set_mapping('n', g:magit_edit_mapping,
\ "magit#jump_to()", '\<\%(un\)\?staged\>')
\ "magit#jump_to('rightbelow vnew')", '\<\%(un\)\?staged\>')
call s:mg_set_mapping('n', g:magit_edit_horyzontal_mapping,
\ "magit#jump_to('rightbelow new')", '\<\%(un\)\?staged\>')

call s:mg_set_mapping('n', g:magit_reload_mapping,
\ "magit#update_buffer()")
Expand Down Expand Up @@ -186,6 +189,8 @@ function! magit#mapping#set_default()
\.' if cursor on filename header or hunk, unstage whole file',
\g:magit_edit_mapping
\.' edit, jump cursor to file containing this hunk',
\g:magit_edit_horyzontal_mapping
\.' edit, jump cursor to file containing this hunk (horyzontal split if buffer not opened)',
\g:magit_jump_next_hunk.','.g:magit_jump_prev_hunk
\. ' move to Next/Previous hunk in magit buffer',
\],
Expand Down
5 changes: 3 additions & 2 deletions plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,8 @@ endfunction
" hunk
" if this file is already displayed in a window, jump to the window, if not,
" jump to last window and open buffer, at the beginning of the hunk
function! magit#jump_to()
" param[in] newwin_cmd: vim command to execute to open the new window
function! magit#jump_to(newwin_cmd)
let section=magit#helper#get_section()
let filename=fnameescape(magit#git#top_dir() . magit#helper#get_filename())
let header_line_nb=magit#helper#get_hunkheader_line_nb()
Expand All @@ -1234,7 +1235,7 @@ function! magit#jump_to()
let buf_win = magit#utils#search_buffer_in_windows(filename)
let buf_win = ( buf_win == 0 ) ? last_win : buf_win
if ( buf_win == 0 || winnr('$') == 1 )
rightbelow vnew
execute a:newwin_cmd
else
execute buf_win."wincmd w"
endif
Expand Down