diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index d0696c7..1ca08a5 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1821,8 +1821,8 @@ function! fugitive#BufReadStatus() abort exe "nnoremap " nowait "u :execute Do('Unstage',0)" exe "xnoremap " nowait "u :execute Do('Unstage',1)" nnoremap U :exe EchoExec('reset', '-q') - call s:MapEx('gu', "exe StageJump(v:count, 'Unstaged')") - call s:MapEx('gU', "exe StageJump(v:count, 'Untracked')") + call s:MapEx('gu', "exe StageJump(v:count, 'Untracked', 'Unstaged')") + call s:MapEx('gU', "exe StageJump(v:count, 'Unstaged', 'Untracked')") call s:MapEx('gs', "exe StageJump(v:count, 'Staged')") call s:MapEx('gp', "exe StageJump(v:count, 'Unpushed')") call s:MapEx('gP', "exe StageJump(v:count, 'Unpulled')") @@ -2248,13 +2248,19 @@ function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args endfunction 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 exe line if a:offset for i in range(a:offset) 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 '' endif endfor diff --git a/doc/fugitive.txt b/doc/fugitive.txt index 3d2157b..fd1ad67 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -377,10 +377,11 @@ i Jump to the next file or hunk, expanding inline diffs ][ Jump [count] section ends forward. *fugitive_gu* -gu Jump to file [count] in the "Unstaged" section. +gu Jump to file [count] in the "Untracked" or "Unstaged" + section. *fugitive_gU* -gU Jump to file [count] in the "Untracked" section. +gU Jump to file [count] in the "Unstaged" section. *fugitive_gs* gs Jump to file [count] in the "Staged" section.