Skip to content

Commit

Permalink
plugin/magit.vim: add reset mapping in diff context ref #97
Browse files Browse the repository at this point in the history
  • Loading branch information
jreybert committed Oct 12, 2016
1 parent a422a3e commit 4a067f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ E means 'edit'.
##### R
* Refresh magit buffer

##### -,+
* Shrink,enlarge diff context
##### -,+,0
* Shrink,enlarge,reset diff context

##### q
* Close the magit buffer
Expand Down
13 changes: 6 additions & 7 deletions doc/vimagit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,14 @@ Following mappings are set locally, for magit buffer only, in normal mode.
*vimagit-g:magit_reload_mapping*
R Refresh magit buffer.

*magit#update_diff()*
*vimagit--* *vimagit-g:magit_diff_shrink*
*vimagit-+* *vimagit-g:magit_diff_enlarge*
*vimagit-0* *vimagit-g:magit_diff_reset*
-,+,0 Shrink,enlarge,reset diff context

*vimagit-q*
*vimagit-g:magit_close_mapping*

*vimagit--* *magit#update_diff()*
*vimagit-+*
*vimagit-g:magit_diff_shrink*
*vimagit-g:magit_diff_enlarge*
-,+ Shrink,enlarge diff context

q close magit buffer.

*vimagit-?* *magit#toggle_help()*
Expand Down
8 changes: 6 additions & 2 deletions plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ let g:magit_toggle_help_mapping = get(g:, 'magit_toggle_help_mapping',

let g:magit_diff_shrink = get(g:, 'magit_diff_shrink', '-' )
let g:magit_diff_enlarge = get(g:, 'magit_diff_enlarge', '+' )
let g:magit_diff_reset = get(g:, 'magit_diff_reset', '0' )

let g:magit_folding_toggle_mapping = get(g:, 'magit_folding_toggle_mapping', [ '<CR>' ])
let g:magit_folding_open_mapping = get(g:, 'magit_folding_open_mapping', [ 'zo', 'zO' ])
Expand Down Expand Up @@ -117,8 +118,8 @@ let s:magit_inline_help = {
\. ' commit undo, cancel and close current commit message',
\g:magit_reload_mapping
\.' refresh magit buffer',
\g:magit_diff_shrink.','.g:magit_diff_enlarge
\. ' shrink,enlarge diff context',
\g:magit_diff_shrink.','.g:magit_diff_enlarge.','.g:magit_diff_reset
\. ' shrink,enlarge,reset diff context',
\g:magit_close_mapping
\.' close magit buffer',
\g:magit_toggle_help_mapping
Expand Down Expand Up @@ -811,6 +812,7 @@ function! magit#show_magit(display, ...)
execute "nnoremap <buffer> <silent> " . g:magit_close_mapping . " :call magit#close_magit()<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_diff_shrink . " :call magit#update_diff('-')<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_diff_enlarge . " :call magit#update_diff('+')<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_diff_reset . " :call magit#update_diff('0')<cr>"
execute "nnoremap <buffer> <silent> " . g:magit_toggle_help_mapping . " :call magit#toggle_help()<cr>"

execute "nnoremap <buffer> <silent> " . g:magit_stage_line_mapping . " :call magit#stage_vselect()<cr>"
Expand Down Expand Up @@ -1185,6 +1187,8 @@ endfunction
function! magit#update_diff(way)
if ( a:way == "+" )
let b:magit_diff_context+=1
elseif ( a:way == "0" )
let b:magit_diff_context=3
elseif ( b:magit_diff_context > 1 )
let b:magit_diff_context-=1
endif
Expand Down

0 comments on commit 4a067f2

Please sign in to comment.