Swap gu and gU

This commit is contained in:
Tim Pope 2019-08-06 15:39:01 -04:00
parent 0cc3beeae9
commit 511e32114b
2 changed files with 13 additions and 6 deletions

View File

@ -1821,8 +1821,8 @@ function! fugitive#BufReadStatus() abort
exe "nnoremap <buffer> <silent>" nowait "u :<C-U>execute <SID>Do('Unstage',0)<CR>" exe "nnoremap <buffer> <silent>" nowait "u :<C-U>execute <SID>Do('Unstage',0)<CR>"
exe "xnoremap <buffer> <silent>" nowait "u :<C-U>execute <SID>Do('Unstage',1)<CR>" exe "xnoremap <buffer> <silent>" nowait "u :<C-U>execute <SID>Do('Unstage',1)<CR>"
nnoremap <buffer> <silent> U :exe <SID>EchoExec('reset', '-q')<CR> nnoremap <buffer> <silent> U :exe <SID>EchoExec('reset', '-q')<CR>
call s:MapEx('gu', "exe <SID>StageJump(v:count, 'Unstaged')") call s:MapEx('gu', "exe <SID>StageJump(v:count, 'Untracked', 'Unstaged')")
call s:MapEx('gU', "exe <SID>StageJump(v:count, 'Untracked')") call s:MapEx('gU', "exe <SID>StageJump(v:count, 'Unstaged', 'Untracked')")
call s:MapEx('gs', "exe <SID>StageJump(v:count, 'Staged')") call s:MapEx('gs', "exe <SID>StageJump(v:count, 'Staged')")
call s:MapEx('gp', "exe <SID>StageJump(v:count, 'Unpushed')") call s:MapEx('gp', "exe <SID>StageJump(v:count, 'Unpushed')")
call s:MapEx('gP', "exe <SID>StageJump(v:count, 'Unpulled')") call s:MapEx('gP', "exe <SID>StageJump(v:count, 'Unpulled')")
@ -2248,13 +2248,19 @@ function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args
endfunction endfunction
function! s:StageJump(offset, section, ...) abort function! s:StageJump(offset, section, ...) abort
let line = search('^' . a:section, 'nw') let line = search('^\%(' . a:section . '\)', 'nw')
if !line && a:0
let line = search('^\%(' . a:1 . '\)', 'nw')
endif
if line if line
exe line exe line
if a:offset if a:offset
for i in range(a:offset) for i in range(a:offset)
call search(s:file_pattern . '\|^$') call search(s:file_pattern . '\|^$')
if empty(line('.')) if empty(getline('.')) && a:0 && getline(line('.') + 1) =~# '^\%(' . a:1 . '\)'
call search(s:file_pattern . '\|^$')
endif
if empty(getline('.'))
return '' return ''
endif endif
endfor endfor

View File

@ -377,10 +377,11 @@ i Jump to the next file or hunk, expanding inline diffs
][ Jump [count] section ends forward. ][ Jump [count] section ends forward.
*fugitive_gu* *fugitive_gu*
gu Jump to file [count] in the "Unstaged" section. gu Jump to file [count] in the "Untracked" or "Unstaged"
section.
*fugitive_gU* *fugitive_gU*
gU Jump to file [count] in the "Untracked" section. gU Jump to file [count] in the "Unstaged" section.
*fugitive_gs* *fugitive_gs*
gs Jump to file [count] in the "Staged" section. gs Jump to file [count] in the "Staged" section.