Skip to content

Instantly share code, notes, and snippets.

@avonmoll
Created March 14, 2018 18:05
Show Gist options
  • Save avonmoll/0a9131a52e5fad48a4f9141c105eb52f to your computer and use it in GitHub Desktop.
Save avonmoll/0a9131a52e5fad48a4f9141c105eb52f to your computer and use it in GitHub Desktop.
Profile for vim-gitgutter
SCRIPT /Users/vonmolal/.vim/bundle/vim-gitgutter/plugin/gitgutter.vim
Sourced 1 time
Total time: 0.001729
Self time: 0.000896
count total (s) self (s)
1 0.000004 scriptencoding utf-8
1 0.000008 if exists('g:loaded_gitgutter') || !has('signs') || &cp
finish
endif
1 0.000002 let g:loaded_gitgutter = 1
" Initialisation {{{
1 0.000002 if v:version < 703 || (v:version == 703 && !has("patch105"))
call gitgutter#utility#warn('requires Vim 7.3.105')
finish
endif
1 0.000002 function! s:set(var, default) abort
if !exists(a:var)
if type(a:default)
execute 'let' a:var '=' string(a:default)
else
execute 'let' a:var '=' a:default
endif
endif
endfunction
1 0.000017 0.000004 call s:set('g:gitgutter_enabled', 1)
1 0.000012 0.000002 call s:set('g:gitgutter_max_signs', 500)
1 0.000011 0.000002 call s:set('g:gitgutter_signs', 1)
1 0.000012 0.000003 call s:set('g:gitgutter_highlight_lines', 0)
1 0.000011 0.000001 call s:set('g:gitgutter_sign_column_always', 0)
1 0.000002 if g:gitgutter_sign_column_always && exists('&signcolumn')
" Vim 7.4.2201.
set signcolumn=yes
let g:gitgutter_sign_column_always = 0
call gitgutter#utility#warn('please replace "let g:gitgutter_sign_column_always=1" with "set signcolumn=yes"')
endif
1 0.000010 0.000003 call s:set('g:gitgutter_override_sign_column_highlight', 1)
1 0.000013 0.000003 call s:set('g:gitgutter_sign_added', '+')
1 0.000014 0.000002 call s:set('g:gitgutter_sign_modified', '~')
1 0.000018 0.000002 call s:set('g:gitgutter_sign_removed', '_')
1 0.000357 0.000146 if gitgutter#utility#supports_overscore_sign()
1 0.000025 0.000004 call s:set('g:gitgutter_sign_removed_first_line', '‾')
1 0.000000 else
call s:set('g:gitgutter_sign_removed_first_line', '_^')
endif
1 0.000017 0.000004 call s:set('g:gitgutter_sign_modified_removed', '~_')
1 0.000014 0.000002 call s:set('g:gitgutter_diff_args', '')
1 0.000014 0.000003 call s:set('g:gitgutter_diff_base', '')
1 0.000013 0.000002 call s:set('g:gitgutter_map_keys', 1)
1 0.000010 0.000003 call s:set('g:gitgutter_terminal_reports_focus', 1)
1 0.000012 0.000002 call s:set('g:gitgutter_async', 1)
1 0.000012 0.000002 call s:set('g:gitgutter_log', 0)
1 0.000014 0.000003 call s:set('g:gitgutter_git_executable', 'git')
1 0.000042 if !executable(g:gitgutter_git_executable)
call gitgutter#utility#warn('cannot find git. Please set g:gitgutter_git_executable.')
endif
1 0.000003 let default_grep = 'grep'
1 0.000011 0.000004 call s:set('g:gitgutter_grep', default_grep)
1 0.000002 if !empty(g:gitgutter_grep)
if executable(split(g:gitgutter_grep)[0])
if $GREP_OPTIONS =~# '--color=always'
let g:gitgutter_grep .= ' --color=never'
endif
else
if g:gitgutter_grep !=# default_grep
call gitgutter#utility#warn('cannot find '.g:gitgutter_grep.'. Please check g:gitgutter_grep.')
endif
let g:gitgutter_grep = ''
endif
endif
1 0.000291 0.000144 call gitgutter#highlight#define_sign_column_highlight()
1 0.000210 0.000006 call gitgutter#highlight#define_highlights()
1 0.000066 0.000004 call gitgutter#highlight#define_signs()
" }}}
" Primary functions {{{
1 0.000005 command! -bar GitGutterAll call gitgutter#all(1)
1 0.000005 command! -bar GitGutter call gitgutter#process_buffer(bufnr(''), 1)
1 0.000003 command! -bar GitGutterDisable call gitgutter#disable()
1 0.000004 command! -bar GitGutterEnable call gitgutter#enable()
1 0.000003 command! -bar GitGutterToggle call gitgutter#toggle()
" }}}
" Line highlights {{{
1 0.000004 command! -bar GitGutterLineHighlightsDisable call gitgutter#highlight#line_disable()
1 0.000005 command! -bar GitGutterLineHighlightsEnable call gitgutter#highlight#line_enable()
1 0.000004 command! -bar GitGutterLineHighlightsToggle call gitgutter#highlight#line_toggle()
" }}}
" Signs {{{
1 0.000004 command! -bar GitGutterSignsEnable call gitgutter#sign#enable()
1 0.000003 command! -bar GitGutterSignsDisable call gitgutter#sign#disable()
1 0.000003 command! -bar GitGutterSignsToggle call gitgutter#sign#toggle()
" }}}
" Hunks {{{
1 0.000006 command! -bar -count=1 GitGutterNextHunk call gitgutter#hunk#next_hunk(<count>)
1 0.000005 command! -bar -count=1 GitGutterPrevHunk call gitgutter#hunk#prev_hunk(<count>)
1 0.000003 command! -bar GitGutterStageHunk call gitgutter#hunk#stage()
1 0.000004 command! -bar GitGutterUndoHunk call gitgutter#hunk#undo()
1 0.000003 command! -bar GitGutterPreviewHunk call gitgutter#hunk#preview()
" Hunk text object
1 0.000010 onoremap <silent> <Plug>GitGutterTextObjectInnerPending :<C-U>call gitgutter#hunk#text_object(1)<CR>
1 0.000009 onoremap <silent> <Plug>GitGutterTextObjectOuterPending :<C-U>call gitgutter#hunk#text_object(0)<CR>
1 0.000009 xnoremap <silent> <Plug>GitGutterTextObjectInnerVisual :<C-U>call gitgutter#hunk#text_object(1)<CR>
1 0.000008 xnoremap <silent> <Plug>GitGutterTextObjectOuterVisual :<C-U>call gitgutter#hunk#text_object(0)<CR>
" Returns the git-diff hunks for the file or an empty list if there
" aren't any hunks.
"
" The return value is a list of lists. There is one inner list per hunk.
"
" [
" [from_line, from_count, to_line, to_count],
" [from_line, from_count, to_line, to_count],
" ...
" ]
"
" where:
"
" `from` - refers to the staged file
" `to` - refers to the working tree's file
" `line` - refers to the line number where the change starts
" `count` - refers to the number of lines the change covers
1 0.000001 function! GitGutterGetHunks()
let bufnr = bufnr('')
return gitgutter#utility#is_active(bufnr) ? gitgutter#hunk#hunks(bufnr) : []
endfunction
" Returns an array that contains a summary of the hunk status for the current
" window. The format is [ added, modified, removed ], where each value
" represents the number of lines added/modified/removed respectively.
1 0.000001 function! GitGutterGetHunkSummary()
return gitgutter#hunk#summary(winbufnr(0))
endfunction
" }}}
1 0.000003 command! -bar GitGutterDebug call gitgutter#debug#debug()
" Maps {{{
1 0.000014 nnoremap <silent> <expr> <Plug>GitGutterNextHunk &diff ? ']c' : ":\<C-U>execute v:count1 . 'GitGutterNextHunk'\<CR>"
1 0.000010 nnoremap <silent> <expr> <Plug>GitGutterPrevHunk &diff ? '[c' : ":\<C-U>execute v:count1 . 'GitGutterPrevHunk'\<CR>"
1 0.000001 if g:gitgutter_map_keys
1 0.000011 if !hasmapto('<Plug>GitGutterPrevHunk') && maparg('[c', 'n') ==# ''
1 0.000005 nmap [c <Plug>GitGutterPrevHunk
1 0.000001 endif
1 0.000009 if !hasmapto('<Plug>GitGutterNextHunk') && maparg(']c', 'n') ==# ''
1 0.000005 nmap ]c <Plug>GitGutterNextHunk
1 0.000000 endif
1 0.000001 endif
1 0.000007 nnoremap <silent> <Plug>GitGutterStageHunk :GitGutterStageHunk<CR>
1 0.000006 nnoremap <silent> <Plug>GitGutterUndoHunk :GitGutterUndoHunk<CR>
1 0.000007 nnoremap <silent> <Plug>GitGutterPreviewHunk :GitGutterPreviewHunk<CR>
1 0.000001 if g:gitgutter_map_keys
1 0.000010 if !hasmapto('<Plug>GitGutterStageHunk') && maparg('<Leader>hs', 'n') ==# ''
1 0.000006 nmap <Leader>hs <Plug>GitGutterStageHunk
1 0.000001 endif
1 0.000009 if !hasmapto('<Plug>GitGutterUndoHunk') && maparg('<Leader>hu', 'n') ==# ''
1 0.000006 nmap <Leader>hu <Plug>GitGutterUndoHunk
1 0.000001 endif
1 0.000010 if !hasmapto('<Plug>GitGutterPreviewHunk') && maparg('<Leader>hp', 'n') ==# ''
1 0.000006 nmap <Leader>hp <Plug>GitGutterPreviewHunk
1 0.000000 endif
1 0.000010 if !hasmapto('<Plug>GitGutterTextObjectInnerPending') && maparg('ic', 'o') ==# ''
1 0.000006 omap ic <Plug>GitGutterTextObjectInnerPending
1 0.000000 endif
1 0.000010 if !hasmapto('<Plug>GitGutterTextObjectOuterPending') && maparg('ac', 'o') ==# ''
1 0.000006 omap ac <Plug>GitGutterTextObjectOuterPending
1 0.000001 endif
1 0.000009 if !hasmapto('<Plug>GitGutterTextObjectInnerVisual') && maparg('ic', 'x') ==# ''
1 0.000005 xmap ic <Plug>GitGutterTextObjectInnerVisual
1 0.000001 endif
1 0.000009 if !hasmapto('<Plug>GitGutterTextObjectOuterVisual') && maparg('ac', 'x') ==# ''
1 0.000006 xmap ac <Plug>GitGutterTextObjectOuterVisual
1 0.000001 endif
1 0.000000 endif
" }}}
" Autocommands {{{
1 0.000002 augroup gitgutter
1 0.000045 autocmd!
1 0.000005 autocmd TabEnter * let t:gitgutter_didtabenter = 1
1 0.000006 autocmd BufEnter *
\ if exists('t:gitgutter_didtabenter') && t:gitgutter_didtabenter |
\ let t:gitgutter_didtabenter = 0 |
\ call gitgutter#all(!g:gitgutter_terminal_reports_focus) |
\ else |
\ call gitgutter#init_buffer(bufnr('')) |
\ call gitgutter#process_buffer(bufnr(''), !g:gitgutter_terminal_reports_focus) |
\ endif
1 0.000005 autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(bufnr(''), 0)
1 0.000008 autocmd FileChangedShellPost,ShellCmdPost * call gitgutter#process_buffer(bufnr(''), 1)
" Ensure that all buffers are processed when opening vim with multiple files, e.g.:
"
" vim -o file1 file2
1 0.000003 autocmd VimEnter * if winnr() != winnr('$') | call gitgutter#all(0) | endif
1 0.000002 autocmd FocusGained * call gitgutter#all(1)
1 0.000002 autocmd ColorScheme * call gitgutter#highlight#define_sign_column_highlight() | call gitgutter#highlight#define_highlights()
" Disable during :vimgrep
1 0.000004 autocmd QuickFixCmdPre *vimgrep* let g:gitgutter_enabled = 0
1 0.000003 autocmd QuickFixCmdPost *vimgrep* let g:gitgutter_enabled = 1
1 0.000001 augroup END
" }}}
" vim:set et sw=2 fdm=marker:
SCRIPT /Users/vonmolal/.vim/bundle/vim-gitgutter/autoload/gitgutter/utility.vim
Sourced 1 time
Total time: 0.000182
Self time: 0.000182
count total (s) self (s)
1 0.000003 function! gitgutter#utility#supports_overscore_sign()
if s:windows()
return &encoding ==? 'utf-8'
else
return &termencoding ==? &encoding || &termencoding == ''
endif
endfunction
1 0.000002 function! gitgutter#utility#setbufvar(buffer, varname, val)
let dict = get(getbufvar(a:buffer, ''), 'gitgutter', {})
let needs_setting = empty(dict)
let dict[a:varname] = a:val
if needs_setting
call setbufvar(a:buffer, 'gitgutter', dict)
endif
endfunction
1 0.000010 function! gitgutter#utility#getbufvar(buffer, varname, ...)
let dict = get(getbufvar(a:buffer, ''), 'gitgutter', {})
if has_key(dict, a:varname)
return dict[a:varname]
else
if a:0
return a:1
endif
endif
endfunction
1 0.000002 function! gitgutter#utility#warn(message) abort
echohl WarningMsg
echo 'vim-gitgutter: ' . a:message
echohl None
let v:warningmsg = a:message
endfunction
1 0.000002 function! gitgutter#utility#warn_once(bufnr, message, key) abort
if empty(gitgutter#utility#getbufvar(a:bufnr, a:key))
call gitgutter#utility#setbufvar(a:bufnr, a:key, '1')
echohl WarningMsg
redraw | echom 'vim-gitgutter: ' . a:message
echohl None
let v:warningmsg = a:message
endif
endfunction
" Returns truthy when the buffer's file should be processed; and falsey when it shouldn't.
" This function does not and should not make any system calls.
1 0.000001 function! gitgutter#utility#is_active(bufnr) abort
return g:gitgutter_enabled &&
\ !pumvisible() &&
\ s:is_file_buffer(a:bufnr) &&
\ s:exists_file(a:bufnr) &&
\ s:not_git_dir(a:bufnr) &&
\ !s:vimdiff(a:bufnr)
endfunction
1 0.000002 function! s:not_git_dir(bufnr) abort
return s:dir(a:bufnr) !~ '[/\\]\.git\($\|[/\\]\)'
endfunction
1 0.000001 function! s:is_file_buffer(bufnr) abort
return empty(getbufvar(a:bufnr, '&buftype'))
endfunction
" From tpope/vim-fugitive
1 0.000002 function! s:winshell()
return &shell =~? 'cmd' || exists('+shellslash') && !&shellslash
endfunction
" From tpope/vim-fugitive
1 0.000001 function! gitgutter#utility#shellescape(arg) abort
if a:arg =~ '^[A-Za-z0-9_/.-]\+$'
return a:arg
elseif s:winshell()
return '"' . substitute(substitute(a:arg, '"', '""', 'g'), '%', '"%"', 'g') . '"'
else
return shellescape(a:arg)
endif
endfunction
1 0.000001 function! gitgutter#utility#file(bufnr)
return s:abs_path(a:bufnr, 1)
endfunction
" Not shellescaped
1 0.000002 function! gitgutter#utility#extension(bufnr) abort
return fnamemodify(s:abs_path(a:bufnr, 0), ':e')
endfunction
1 0.000001 function! gitgutter#utility#system(cmd, ...) abort
call gitgutter#debug#log(a:cmd, a:000)
call s:use_known_shell()
silent let output = (a:0 == 0) ? system(a:cmd) : system(a:cmd, a:1)
call s:restore_shell()
return output
endfunction
" Path of file relative to repo root.
"
" * empty string - not set
" * non-empty string - path
" * -1 - pending
" * -2 - not tracked by git
1 0.000002 function! gitgutter#utility#repo_path(bufnr, shellesc) abort
let p = gitgutter#utility#getbufvar(a:bufnr, 'path')
return a:shellesc ? gitgutter#utility#shellescape(p) : p
endfunction
1 0.000002 function! gitgutter#utility#set_repo_path(bufnr) abort
" Values of path:
" * non-empty string - path
" * -1 - pending
" * -2 - not tracked by git
call gitgutter#utility#setbufvar(a:bufnr, 'path', -1)
let cmd = gitgutter#utility#cd_cmd(a:bufnr, g:gitgutter_git_executable.' ls-files --error-unmatch --full-name '.gitgutter#utility#shellescape(s:filename(a:bufnr)))
if g:gitgutter_async && gitgutter#async#available()
if has('lambda')
call gitgutter#async#execute(cmd, a:bufnr, {
\ 'out': {bufnr, path -> gitgutter#utility#setbufvar(bufnr, 'path', s:strip_trailing_new_line(path))},
\ 'err': {bufnr -> gitgutter#utility#setbufvar(bufnr, 'path', -2)},
\ })
else
call gitgutter#async#execute(cmd, a:bufnr, {
\ 'out': function('s:set_path'),
\ 'err': function('s:set_path', [-2])
\ })
endif
else
let path = gitgutter#utility#system(cmd)
if v:shell_error
call gitgutter#utility#setbufvar(a:bufnr, 'path', -2)
else
call gitgutter#utility#setbufvar(a:bufnr, 'path', s:strip_trailing_new_line(path))
endif
endif
endfunction
1 0.000002 function! s:set_path(bufnr, path)
if a:bufnr == -2
let [bufnr, path] = [a:path, a:bufnr]
call gitgutter#utility#setbufvar(bufnr, 'path', path)
else
call gitgutter#utility#setbufvar(a:bufnr, 'path', s:strip_trailing_new_line(a:path))
endif
endfunction
1 0.000001 function! gitgutter#utility#cd_cmd(bufnr, cmd) abort
let cd = s:unc_path(a:bufnr) ? 'pushd' : (s:windows() ? 'cd /d' : 'cd')
return cd.' '.s:dir(a:bufnr).' && '.a:cmd
endfunction
1 0.000001 function! s:unc_path(bufnr)
return s:abs_path(a:bufnr, 0) =~ '^\\\\'
endfunction
1 0.000001 function! s:use_known_shell() abort
if has('unix') && &shell !=# 'sh'
let [s:shell, s:shellcmdflag, s:shellredir] = [&shell, &shellcmdflag, &shellredir]
let &shell = 'sh'
set shellcmdflag=-c shellredir=>%s\ 2>&1
endif
endfunction
1 0.000001 function! s:restore_shell() abort
if has('unix') && exists('s:shell')
let [&shell, &shellcmdflag, &shellredir] = [s:shell, s:shellcmdflag, s:shellredir]
endif
endfunction
1 0.000001 function! s:abs_path(bufnr, shellesc)
let p = resolve(expand('#'.a:bufnr.':p'))
return a:shellesc ? gitgutter#utility#shellescape(p) : p
endfunction
1 0.000001 function! s:dir(bufnr) abort
return gitgutter#utility#shellescape(fnamemodify(s:abs_path(a:bufnr, 0), ':h'))
endfunction
" Not shellescaped.
1 0.000001 function! s:filename(bufnr) abort
return fnamemodify(s:abs_path(a:bufnr, 0), ':t')
endfunction
1 0.000001 function! s:exists_file(bufnr) abort
return filereadable(s:abs_path(a:bufnr, 0))
endfunction
1 0.000001 function! s:strip_trailing_new_line(line) abort
return substitute(a:line, '\n$', '', '')
endfunction
" Returns 1 if any of the given buffer's windows has the `&diff` option set,
" or 0 otherwise.
1 0.000003 if exists('*win_findbuf')
1 0.000001 function! s:vimdiff(bufnr) abort
for winid in win_findbuf(a:bufnr)
if getwinvar(winid, '&diff')
return 1
endif
endfor
return 0
endfunction
1 0.000001 else
function! s:vimdiff(bufnr) abort
for winnr in range(1, winnr('$'))
if winbufnr(winnr) == a:bufnr && getwinvar(winnr, '&diff')
return 1
endif
endfor
return 0
endfunction
endif
1 0.000001 function! s:windows()
return has('win64') || has('win32') || has('win16')
endfunction
SCRIPT /Users/vonmolal/.vim/bundle/vim-gitgutter/autoload/gitgutter/highlight.vim
Sourced 1 time
Total time: 0.000123
Self time: 0.000123
count total (s) self (s)
1 0.000003 function! gitgutter#highlight#line_disable() abort
let g:gitgutter_highlight_lines = 0
call s:define_sign_line_highlights()
if !g:gitgutter_signs
call gitgutter#sign#clear_signs(bufnr(''))
call gitgutter#sign#remove_dummy_sign(bufnr(''), 0)
endif
redraw!
endfunction
1 0.000001 function! gitgutter#highlight#line_enable() abort
let old_highlight_lines = g:gitgutter_highlight_lines
let g:gitgutter_highlight_lines = 1
call s:define_sign_line_highlights()
if !old_highlight_lines && !g:gitgutter_signs
call gitgutter#all(1)
endif
redraw!
endfunction
1 0.000001 function! gitgutter#highlight#line_toggle() abort
if g:gitgutter_highlight_lines
call gitgutter#highlight#line_disable()
else
call gitgutter#highlight#line_enable()
endif
endfunction
1 0.000002 function! gitgutter#highlight#define_sign_column_highlight() abort
if g:gitgutter_override_sign_column_highlight
highlight! link SignColumn LineNr
else
highlight default link SignColumn LineNr
endif
endfunction
1 0.000001 function! gitgutter#highlight#define_highlights() abort
let [guibg, ctermbg] = s:get_background_colors('SignColumn')
" Highlights used by the signs.
execute "highlight GitGutterAddDefault guifg=#009900 guibg=" . guibg . " ctermfg=2 ctermbg=" . ctermbg
execute "highlight GitGutterChangeDefault guifg=#bbbb00 guibg=" . guibg . " ctermfg=3 ctermbg=" . ctermbg
execute "highlight GitGutterDeleteDefault guifg=#ff2222 guibg=" . guibg . " ctermfg=1 ctermbg=" . ctermbg
highlight default link GitGutterChangeDeleteDefault GitGutterChangeDefault
execute "highlight GitGutterAddInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
execute "highlight GitGutterChangeInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
execute "highlight GitGutterDeleteInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
highlight default link GitGutterChangeDeleteInvisible GitGutterChangeInvisible
highlight default link GitGutterAdd GitGutterAddDefault
highlight default link GitGutterChange GitGutterChangeDefault
highlight default link GitGutterDelete GitGutterDeleteDefault
highlight default link GitGutterChangeDelete GitGutterChangeDeleteDefault
" Highlights used for the whole line.
highlight default link GitGutterAddLine DiffAdd
highlight default link GitGutterChangeLine DiffChange
highlight default link GitGutterDeleteLine DiffDelete
highlight default link GitGutterChangeDeleteLine GitGutterChangeLine
endfunction
1 0.000001 function! gitgutter#highlight#define_signs() abort
sign define GitGutterLineAdded
sign define GitGutterLineModified
sign define GitGutterLineRemoved
sign define GitGutterLineRemovedFirstLine
sign define GitGutterLineModifiedRemoved
sign define GitGutterDummy
call s:define_sign_text()
call gitgutter#highlight#define_sign_text_highlights()
call s:define_sign_line_highlights()
endfunction
1 0.000002 function! s:define_sign_text() abort
execute "sign define GitGutterLineAdded text=" . g:gitgutter_sign_added
execute "sign define GitGutterLineModified text=" . g:gitgutter_sign_modified
execute "sign define GitGutterLineRemoved text=" . g:gitgutter_sign_removed
execute "sign define GitGutterLineRemovedFirstLine text=" . g:gitgutter_sign_removed_first_line
execute "sign define GitGutterLineModifiedRemoved text=" . g:gitgutter_sign_modified_removed
endfunction
1 0.000002 function! gitgutter#highlight#define_sign_text_highlights() abort
" Once a sign's text attribute has been defined, it cannot be undefined or
" set to an empty value. So to make signs' text disappear (when toggling
" off or disabling) we make them invisible by setting their foreground colours
" to the background's.
if g:gitgutter_signs
sign define GitGutterLineAdded texthl=GitGutterAdd
sign define GitGutterLineModified texthl=GitGutterChange
sign define GitGutterLineRemoved texthl=GitGutterDelete
sign define GitGutterLineRemovedFirstLine texthl=GitGutterDelete
sign define GitGutterLineModifiedRemoved texthl=GitGutterChangeDelete
else
sign define GitGutterLineAdded texthl=GitGutterAddInvisible
sign define GitGutterLineModified texthl=GitGutterChangeInvisible
sign define GitGutterLineRemoved texthl=GitGutterDeleteInvisible
sign define GitGutterLineRemovedFirstLine texthl=GitGutterDeleteInvisible
sign define GitGutterLineModifiedRemoved texthl=GitGutterChangeDeleteInvisible
endif
endfunction
1 0.000002 function! s:define_sign_line_highlights() abort
if g:gitgutter_highlight_lines
sign define GitGutterLineAdded linehl=GitGutterAddLine
sign define GitGutterLineModified linehl=GitGutterChangeLine
sign define GitGutterLineRemoved linehl=GitGutterDeleteLine
sign define GitGutterLineRemovedFirstLine linehl=GitGutterDeleteLine
sign define GitGutterLineModifiedRemoved linehl=GitGutterChangeDeleteLine
else
sign define GitGutterLineAdded linehl=
sign define GitGutterLineModified linehl=
sign define GitGutterLineRemoved linehl=
sign define GitGutterLineRemovedFirstLine linehl=
sign define GitGutterLineModifiedRemoved linehl=
endif
endfunction
1 0.000002 function! s:get_background_colors(group) abort
redir => highlight
silent execute 'silent highlight ' . a:group
redir END
let link_matches = matchlist(highlight, 'links to \(\S\+\)')
if len(link_matches) > 0 " follow the link
return s:get_background_colors(link_matches[1])
endif
let ctermbg = s:match_highlight(highlight, 'ctermbg=\([0-9A-Za-z]\+\)')
let guibg = s:match_highlight(highlight, 'guibg=\([#0-9A-Za-z]\+\)')
return [guibg, ctermbg]
endfunction
1 0.000001 function! s:match_highlight(highlight, pattern) abort
let matches = matchlist(a:highlight, a:pattern)
if len(matches) == 0
return 'NONE'
endif
return matches[1]
endfunction
SCRIPT /Users/vonmolal/.vim/bundle/vim-gitgutter/autoload/gitgutter.vim
Sourced 1 time
Total time: 0.000123
Self time: 0.000123
count total (s) self (s)
1 0.000005 let s:t_string = type('')
" Primary functions {{{
1 0.000002 function! gitgutter#all(force) abort
for bufnr in s:uniq(tabpagebuflist())
let file = expand('#'.bufnr.':p')
if !empty(file)
call gitgutter#init_buffer(bufnr)
call gitgutter#process_buffer(bufnr, a:force)
endif
endfor
endfunction
" Finds the file's path relative to the repo root.
1 0.000001 function! gitgutter#init_buffer(bufnr)
if gitgutter#utility#is_active(a:bufnr)
let p = gitgutter#utility#repo_path(a:bufnr, 0)
if type(p) != s:t_string || empty(p)
call gitgutter#utility#set_repo_path(a:bufnr)
endif
endif
endfunction
1 0.000002 function! gitgutter#process_buffer(bufnr, force) abort
" NOTE a:bufnr is not necessarily the current buffer.
if gitgutter#utility#is_active(a:bufnr)
if a:force || s:has_fresh_changes(a:bufnr)
let diff = ''
try
let diff = gitgutter#diff#run_diff(a:bufnr, 0)
catch /gitgutter not tracked/
call gitgutter#debug#log('Not tracked: '.gitgutter#utility#file(a:bufnr))
catch /gitgutter diff failed/
call gitgutter#debug#log('Diff failed: '.gitgutter#utility#file(a:bufnr))
call gitgutter#hunk#reset(a:bufnr)
endtry
if diff != 'async'
call gitgutter#diff#handler(a:bufnr, diff)
endif
endif
else
call s:clear(a:bufnr)
endif
endfunction
1 0.000001 function! gitgutter#disable() abort
" get list of all buffers (across all tabs)
let buflist = []
for i in range(tabpagenr('$'))
call extend(buflist, tabpagebuflist(i + 1))
endfor
for bufnr in s:uniq(buflist)
let file = expand('#'.bufnr.':p')
if !empty(file)
call s:clear(bufnr)
endif
endfor
let g:gitgutter_enabled = 0
endfunction
1 0.000002 function! gitgutter#enable() abort
let g:gitgutter_enabled = 1
call gitgutter#all(1)
endfunction
1 0.000001 function! gitgutter#toggle() abort
if g:gitgutter_enabled
call gitgutter#disable()
else
call gitgutter#enable()
endif
endfunction
" }}}
1 0.000002 function! s:has_fresh_changes(bufnr) abort
return getbufvar(a:bufnr, 'changedtick') != gitgutter#utility#getbufvar(a:bufnr, 'tick')
endfunction
1 0.000001 function! s:reset_tick(bufnr) abort
call gitgutter#utility#setbufvar(a:bufnr, 'tick', 0)
endfunction
1 0.000001 function! s:clear(bufnr)
call gitgutter#sign#clear_signs(a:bufnr)
call gitgutter#sign#remove_dummy_sign(a:bufnr, 1)
call gitgutter#hunk#reset(a:bufnr)
call s:reset_tick(a:bufnr)
endfunction
1 0.000003 if exists('*uniq') " Vim 7.4.218
1 0.000006 function! s:uniq(list)
return uniq(sort(a:list))
endfunction
1 0.000001 else
function! s:uniq(list)
let processed = []
for e in a:list
if index(processed, e) == -1
call add(processed, e)
endif
endfor
return processed
endfunction
endif
SCRIPT /Users/vonmolal/.vim/bundle/vim-gitgutter/autoload/gitgutter/async.vim
Sourced 1 time
Total time: 0.000113
Self time: 0.000113
count total (s) self (s)
1 0.000019 let s:available = has('nvim') || (
\ has('job') && (
\ (has('patch-7-4-1826') && !has('gui_running')) ||
\ (has('patch-7-4-1850') && has('gui_running')) ||
\ (has('patch-7-4-1832') && has('gui_macvim'))
\ )
\ )
1 0.000002 function! gitgutter#async#available()
return s:available
endfunction
1 0.000001 function! gitgutter#async#execute(cmd, bufnr, handler) abort
call gitgutter#debug#log('[async] '.a:cmd)
let options = {
\ 'stdoutbuffer': [],
\ 'buffer': a:bufnr,
\ 'handler': a:handler
\ }
let command = s:build_command(a:cmd)
if has('nvim')
call jobstart(command, extend(options, {
\ 'on_stdout': function('s:on_stdout_nvim'),
\ 'on_stderr': function('s:on_stderr_nvim'),
\ 'on_exit': function('s:on_exit_nvim')
\ }))
else
call job_start(command, {
\ 'out_cb': function('s:on_stdout_vim', options),
\ 'err_cb': function('s:on_stderr_vim', options),
\ 'close_cb': function('s:on_exit_vim', options)
\ })
endif
endfunction
1 0.000002 function! s:build_command(cmd)
if has('unix')
return ['sh', '-c', a:cmd]
endif
if has('win32')
return has('nvim') ? ['cmd.exe', '/c', a:cmd] : 'cmd.exe /c '.a:cmd
endif
throw 'unknown os'
endfunction
1 0.000002 function! s:on_stdout_nvim(_job_id, data, _event) dict abort
if empty(self.stdoutbuffer)
let self.stdoutbuffer = a:data
else
let self.stdoutbuffer = self.stdoutbuffer[:-2] +
\ [self.stdoutbuffer[-1] . a:data[0]] +
\ a:data[1:]
endif
endfunction
1 0.000001 function! s:on_stderr_nvim(_job_id, _data, _event) dict abort
call self.handler.err(self.buffer)
endfunction
1 0.000002 function! s:on_exit_nvim(_job_id, exit_code, _event) dict abort
if !a:exit_code
call self.handler.out(self.buffer, join(self.stdoutbuffer, "\n"))
endif
endfunction
1 0.000001 function! s:on_stdout_vim(_channel, data) dict abort
call add(self.stdoutbuffer, a:data)
endfunction
1 0.000002 function! s:on_stderr_vim(channel, _data) dict abort
call self.handler.err(self.buffer)
try
call ch_close(a:channel) " so close_cb and its 'out' handler are not triggered
catch /E906/
" noop
endtry
endfunction
1 0.000002 function! s:on_exit_vim(_channel) dict abort
call self.handler.out(self.buffer, join(self.stdoutbuffer, "\n"))
endfunction
SCRIPT /Users/vonmolal/.vim/bundle/vim-gitgutter/autoload/gitgutter/debug.vim
Sourced 1 time
Total time: 0.000130
Self time: 0.000130
count total (s) self (s)
1 0.000013 let s:plugin_dir = expand('<sfile>:p:h:h:h').'/'
1 0.000002 let s:log_file = s:plugin_dir.'gitgutter.log'
1 0.000002 let s:channel_log = s:plugin_dir.'channel.log'
1 0.000002 let s:new_log_session = 1
1 0.000002 function! gitgutter#debug#debug()
" Open a scratch buffer
vsplit __GitGutter_Debug__
normal! ggdG
setlocal buftype=nofile
setlocal bufhidden=delete
setlocal noswapfile
call s:vim_version()
call s:separator()
call s:git_version()
call s:separator()
call s:grep_version()
call s:separator()
call s:option('updatetime')
call s:option('shell')
call s:option('shellcmdflag')
call s:option('shellpipe')
call s:option('shellquote')
call s:option('shellredir')
call s:option('shellslash')
call s:option('shelltemp')
call s:option('shelltype')
call s:option('shellxescape')
call s:option('shellxquote')
endfunction
1 0.000001 function! s:separator()
call s:output('')
endfunction
1 0.000001 function! s:vim_version()
redir => version_info
silent execute 'version'
redir END
call s:output(split(version_info, '\n')[0:2])
endfunction
1 0.000001 function! s:git_version()
let v = system(g:gitgutter_git_executable.' --version')
call s:output( substitute(v, '\n$', '', '') )
endfunction
1 0.000001 function! s:grep_version()
let v = system('grep --version')
call s:output( substitute(v, '\n$', '', '') )
let v = system('grep --help')
call s:output( substitute(v, '\%x00', '', 'g') )
endfunction
1 0.000001 function! s:option(name)
if exists('+' . a:name)
let v = eval('&' . a:name)
call s:output(a:name . '=' . v)
" redir => output
" silent execute "verbose set " . a:name . "?"
" redir END
" call s:output(a:name . '=' . output)
else
call s:output(a:name . ' [n/a]')
end
endfunction
1 0.000001 function! s:output(text)
call append(line('$'), a:text)
endfunction
" assumes optional args are calling function's optional args
1 0.000001 function! gitgutter#debug#log(message, ...) abort
if g:gitgutter_log
if s:new_log_session && gitgutter#async#available()
if exists('*ch_logfile')
call ch_logfile(s:channel_log, 'w')
endif
endif
execute 'redir >> '.s:log_file
if s:new_log_session
let s:start = reltime()
silent echo "\n==== start log session ===="
endif
let elapsed = reltimestr(reltime(s:start)).' '
silent echo ''
" callers excluding this function
silent echo elapsed.expand('<sfile>')[:-22].':'
silent echo elapsed.s:format_for_log(a:message)
if a:0 && !empty(a:1)
for msg in a:000
silent echo elapsed.s:format_for_log(msg)
endfor
endif
redir END
let s:new_log_session = 0
endif
endfunction
1 0.000002 function! s:format_for_log(data) abort
if type(a:data) == 1
return join(split(a:data,'\n'),"\n")
elseif type(a:data) == 3
return '['.join(a:data,"\n").']'
else
return a:data
endif
endfunction
SCRIPT /Users/vonmolal/.vim/bundle/vim-gitgutter/autoload/gitgutter/diff.vim
Sourced 1 time
Total time: 0.026397
Self time: 0.000747
count total (s) self (s)
1 0.000037 let s:nomodeline = (v:version > 703 || (v:version == 703 && has('patch442'))) ? '<nomodeline>' : ''
1 0.000005 let s:hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'
" True for git v1.7.2+.
1 0.000004 function! s:git_supports_command_line_config_override() abort
call system(g:gitgutter_git_executable.' -c foo.bar=baz --version')
return !v:shell_error
endfunction
1 0.025702 0.000052 let s:c_flag = s:git_supports_command_line_config_override()
1 0.000018 let s:temp_index = tempname()
1 0.000008 let s:temp_buffer = tempname()
" Returns a diff of the buffer.
"
" The buffer contents is not the same as the file on disk so we need to pass
" two instances of the file to git-diff:
"
" git diff myfileA myfileB
"
" where myfileA comes from
"
" git show :myfile > myfileA
"
" and myfileB is the buffer contents.
"
" After running the diff we pass it through grep where available to reduce
" subsequent processing by the plugin. If grep is not available the plugin
" does the filtering instead.
"
"
" Regarding line endings:
"
" git-show does not convert line endings.
" git-diff FILE FILE does convert line endings for the given files.
"
" If a file has CRLF line endings and git's core.autocrlf is true,
" the file in git's object store will have LF line endings. Writing
" it out via git-show will produce a file with LF line endings.
"
" If this last file is one of the files passed to git-diff, git-diff will
" convert its line endings to CRLF before diffing -- which is what we want --
" but also by default output a warning on stderr.
"
" warning: LF will be replace by CRLF in <temp file>.
" The file will have its original line endings in your working directory.
"
" When running the diff asynchronously, the warning message triggers the stderr
" callbacks which assume the overall command has failed and reset all the
" signs. As this is not what we want, and we can safely ignore the warning,
" we turn it off by passing the '-c "core.safecrlf=false"' argument to
" git-diff.
"
" When writing the temporary files we preserve the original file's extension
" so that repos using .gitattributes to control EOL conversion continue to
" convert correctly.
1 0.000010 function! gitgutter#diff#run_diff(bufnr, preserve_full_diff) abort
while gitgutter#utility#repo_path(a:bufnr, 0) == -1
sleep 5m
endwhile
if gitgutter#utility#repo_path(a:bufnr, 0) == -2
throw 'gitgutter not tracked'
endif
" Wrap compound commands in parentheses to make Windows happy.
" bash doesn't mind the parentheses.
let cmd = '('
" Append buffer number to avoid race conditions between writing and reading
" the files when asynchronously processing multiple buffers.
"
" Without the buffer number, index_file would have a race in the shell
" between the second process writing it (with git-show) and the first
" reading it (with git-diff).
let index_file = s:temp_index.'.'.a:bufnr
" Without the buffer number, buff_file would have a race between the
" second gitgutter#process_buffer() writing the file (synchronously, below)
" and the first gitgutter#process_buffer()'s async job reading it (with
" git-diff).
let buff_file = s:temp_buffer.'.'.a:bufnr
let extension = gitgutter#utility#extension(a:bufnr)
if !empty(extension)
let index_file .= '.'.extension
let buff_file .= '.'.extension
endif
" Write file from index to temporary file.
let index_name = g:gitgutter_diff_base.':'.gitgutter#utility#repo_path(a:bufnr, 1)
let cmd .= g:gitgutter_git_executable.' --no-pager show '.index_name.' > '.index_file.' && '
" Write buffer to temporary file.
" Note: this is synchronous.
call s:write_buffer(a:bufnr, buff_file)
" Call git-diff with the temporary files.
let cmd .= g:gitgutter_git_executable.' --no-pager'
if s:c_flag
let cmd .= ' -c "diff.autorefreshindex=0"'
let cmd .= ' -c "diff.noprefix=false"'
let cmd .= ' -c "core.safecrlf=false"'
endif
let cmd .= ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args.' -- '.index_file.' '.buff_file
" Pipe git-diff output into grep.
if !a:preserve_full_diff && !empty(g:gitgutter_grep)
let cmd .= ' | '.g:gitgutter_grep.' '.gitgutter#utility#shellescape('^@@ ')
endif
" grep exits with 1 when no matches are found; git-diff exits with 1 when
" differences are found. However we want to treat non-matches and
" differences as non-erroneous behaviour; so we OR the command with one
" which always exits with success (0).
let cmd .= ' || exit 0'
let cmd .= ')'
let cmd = gitgutter#utility#cd_cmd(a:bufnr, cmd)
if g:gitgutter_async && gitgutter#async#available()
call gitgutter#async#execute(cmd, a:bufnr, {
\ 'out': function('gitgutter#diff#handler'),
\ 'err': function('gitgutter#hunk#reset'),
\ })
return 'async'
else
let diff = gitgutter#utility#system(cmd)
if v:shell_error
call gitgutter#debug#log(diff)
throw 'gitgutter diff failed'
endif
return diff
endif
endfunction
1 0.000005 function! gitgutter#diff#handler(bufnr, diff) abort
call gitgutter#debug#log(a:diff)
call gitgutter#hunk#set_hunks(a:bufnr, gitgutter#diff#parse_diff(a:diff))
let modified_lines = gitgutter#diff#process_hunks(a:bufnr, gitgutter#hunk#hunks(a:bufnr))
let signs_count = len(modified_lines)
if signs_count > g:gitgutter_max_signs
call gitgutter#utility#warn_once(a:bufnr, printf(
\ 'exceeded maximum number of signs (%d > %d, configured by g:gitgutter_max_signs).',
\ signs_count, g:gitgutter_max_signs), 'max_signs')
call gitgutter#sign#clear_signs(a:bufnr)
else
if g:gitgutter_signs || g:gitgutter_highlight_lines
call gitgutter#sign#update_signs(a:bufnr, modified_lines)
endif
endif
call s:save_last_seen_change(a:bufnr)
if exists('#User#GitGutter')
let g:gitgutter_hook_context = {'bufnr': a:bufnr}
execute 'doautocmd' s:nomodeline 'User GitGutter'
unlet g:gitgutter_hook_context
endif
endfunction
1 0.000003 function! gitgutter#diff#parse_diff(diff) abort
let hunks = []
for line in split(a:diff, '\n')
let hunk_info = gitgutter#diff#parse_hunk(line)
if len(hunk_info) == 4
call add(hunks, hunk_info)
endif
endfor
return hunks
endfunction
1 0.000002 function! gitgutter#diff#parse_hunk(line) abort
let matches = matchlist(a:line, s:hunk_re)
if len(matches) > 0
let from_line = str2nr(matches[1])
let from_count = (matches[2] == '') ? 1 : str2nr(matches[2])
let to_line = str2nr(matches[3])
let to_count = (matches[4] == '') ? 1 : str2nr(matches[4])
return [from_line, from_count, to_line, to_count]
else
return []
end
endfunction
" This function is public so it may be used by other plugins
" e.g. vim-signature.
1 0.000003 function! gitgutter#diff#process_hunks(bufnr, hunks) abort
let modified_lines = []
for hunk in a:hunks
call extend(modified_lines, s:process_hunk(a:bufnr, hunk))
endfor
return modified_lines
endfunction
" Returns [ [<line_number (number)>, <name (string)>], ...]
1 0.000003 function! s:process_hunk(bufnr, hunk) abort
let modifications = []
let from_line = a:hunk[0]
let from_count = a:hunk[1]
let to_line = a:hunk[2]
let to_count = a:hunk[3]
if s:is_added(from_count, to_count)
call s:process_added(modifications, from_count, to_count, to_line)
call gitgutter#hunk#increment_lines_added(a:bufnr, to_count)
elseif s:is_removed(from_count, to_count)
call s:process_removed(modifications, from_count, to_count, to_line)
call gitgutter#hunk#increment_lines_removed(a:bufnr, from_count)
elseif s:is_modified(from_count, to_count)
call s:process_modified(modifications, from_count, to_count, to_line)
call gitgutter#hunk#increment_lines_modified(a:bufnr, to_count)
elseif s:is_modified_and_added(from_count, to_count)
call s:process_modified_and_added(modifications, from_count, to_count, to_line)
call gitgutter#hunk#increment_lines_added(a:bufnr, to_count - from_count)
call gitgutter#hunk#increment_lines_modified(a:bufnr, from_count)
elseif s:is_modified_and_removed(from_count, to_count)
call s:process_modified_and_removed(modifications, from_count, to_count, to_line)
call gitgutter#hunk#increment_lines_modified(a:bufnr, to_count)
call gitgutter#hunk#increment_lines_removed(a:bufnr, from_count - to_count)
endif
return modifications
endfunction
1 0.000003 function! s:is_added(from_count, to_count) abort
return a:from_count == 0 && a:to_count > 0
endfunction
1 0.000003 function! s:is_removed(from_count, to_count) abort
return a:from_count > 0 && a:to_count == 0
endfunction
1 0.000002 function! s:is_modified(from_count, to_count) abort
return a:from_count > 0 && a:to_count > 0 && a:from_count == a:to_count
endfunction
1 0.000002 function! s:is_modified_and_added(from_count, to_count) abort
return a:from_count > 0 && a:to_count > 0 && a:from_count < a:to_count
endfunction
1 0.000002 function! s:is_modified_and_removed(from_count, to_count) abort
return a:from_count > 0 && a:to_count > 0 && a:from_count > a:to_count
endfunction
1 0.000003 function! s:process_added(modifications, from_count, to_count, to_line) abort
let offset = 0
while offset < a:to_count
let line_number = a:to_line + offset
call add(a:modifications, [line_number, 'added'])
let offset += 1
endwhile
endfunction
1 0.000003 function! s:process_removed(modifications, from_count, to_count, to_line) abort
if a:to_line == 0
call add(a:modifications, [1, 'removed_first_line'])
else
call add(a:modifications, [a:to_line, 'removed'])
endif
endfunction
1 0.000002 function! s:process_modified(modifications, from_count, to_count, to_line) abort
let offset = 0
while offset < a:to_count
let line_number = a:to_line + offset
call add(a:modifications, [line_number, 'modified'])
let offset += 1
endwhile
endfunction
1 0.000003 function! s:process_modified_and_added(modifications, from_count, to_count, to_line) abort
let offset = 0
while offset < a:from_count
let line_number = a:to_line + offset
call add(a:modifications, [line_number, 'modified'])
let offset += 1
endwhile
while offset < a:to_count
let line_number = a:to_line + offset
call add(a:modifications, [line_number, 'added'])
let offset += 1
endwhile
endfunction
1 0.000003 function! s:process_modified_and_removed(modifications, from_count, to_count, to_line) abort
let offset = 0
while offset < a:to_count
let line_number = a:to_line + offset
call add(a:modifications, [line_number, 'modified'])
let offset += 1
endwhile
let a:modifications[-1] = [a:to_line + offset - 1, 'modified_removed']
endfunction
" Returns a diff for the current hunk.
1 0.000003 function! gitgutter#diff#hunk_diff(bufnr, full_diff)
let modified_diff = []
let keep_line = 1
" Don't keepempty when splitting because the diff we want may not be the
" final one. Instead add trailing NL at end of function.
for line in split(a:full_diff, '\n')
let hunk_info = gitgutter#diff#parse_hunk(line)
if len(hunk_info) == 4 " start of new hunk
let keep_line = gitgutter#hunk#cursor_in_hunk(hunk_info)
endif
if keep_line
call add(modified_diff, line)
endif
endfor
return join(modified_diff, "\n")."\n"
endfunction
1 0.000002 function! s:write_buffer(bufnr, file)
let bufcontents = getbufline(a:bufnr, 1, '$')
if getbufvar(a:bufnr, '&fileformat') ==# 'dos'
call map(bufcontents, 'v:val."\r"')
endif
call writefile(bufcontents, a:file)
endfunction
1 0.000002 function! s:save_last_seen_change(bufnr) abort
call gitgutter#utility#setbufvar(a:bufnr, 'tick', getbufvar(a:bufnr, 'changedtick'))
endfunction
SCRIPT /Users/vonmolal/.vim/bundle/vim-gitgutter/autoload/gitgutter/hunk.vim
Sourced 1 time
Total time: 0.000292
Self time: 0.000292
count total (s) self (s)
1 0.000005 function! gitgutter#hunk#set_hunks(bufnr, hunks) abort
call gitgutter#utility#setbufvar(a:bufnr, 'hunks', a:hunks)
call s:reset_summary(a:bufnr)
endfunction
1 0.000007 function! gitgutter#hunk#hunks(bufnr) abort
return gitgutter#utility#getbufvar(a:bufnr, 'hunks', [])
endfunction
1 0.000002 function! gitgutter#hunk#reset(bufnr) abort
call gitgutter#utility#setbufvar(a:bufnr, 'hunks', [])
call s:reset_summary(a:bufnr)
endfunction
1 0.000002 function! gitgutter#hunk#summary(bufnr) abort
return gitgutter#utility#getbufvar(a:bufnr, 'summary', [0,0,0])
endfunction
1 0.000003 function! s:reset_summary(bufnr) abort
call gitgutter#utility#setbufvar(a:bufnr, 'summary', [0,0,0])
endfunction
1 0.000002 function! gitgutter#hunk#increment_lines_added(bufnr, count) abort
let summary = gitgutter#hunk#summary(a:bufnr)
let summary[0] += a:count
call gitgutter#utility#setbufvar(a:bufnr, 'summary', summary)
endfunction
1 0.000002 function! gitgutter#hunk#increment_lines_modified(bufnr, count) abort
let summary = gitgutter#hunk#summary(a:bufnr)
let summary[1] += a:count
call gitgutter#utility#setbufvar(a:bufnr, 'summary', summary)
endfunction
1 0.000001 function! gitgutter#hunk#increment_lines_removed(bufnr, count) abort
let summary = gitgutter#hunk#summary(a:bufnr)
let summary[2] += a:count
call gitgutter#utility#setbufvar(a:bufnr, 'summary', summary)
endfunction
1 0.000001 function! gitgutter#hunk#next_hunk(count) abort
let bufnr = bufnr('')
if gitgutter#utility#is_active(bufnr)
let current_line = line('.')
let hunk_count = 0
for hunk in gitgutter#hunk#hunks(bufnr)
if hunk[2] > current_line
let hunk_count += 1
if hunk_count == a:count
execute 'normal!' hunk[2] . 'Gzv'
return
endif
endif
endfor
call gitgutter#utility#warn('No more hunks')
endif
endfunction
1 0.000001 function! gitgutter#hunk#prev_hunk(count) abort
let bufnr = bufnr('')
if gitgutter#utility#is_active(bufnr)
let current_line = line('.')
let hunk_count = 0
for hunk in reverse(copy(gitgutter#hunk#hunks(bufnr)))
if hunk[2] < current_line
let hunk_count += 1
if hunk_count == a:count
let target = hunk[2] == 0 ? 1 : hunk[2]
execute 'normal!' target . 'Gzv'
return
endif
endif
endfor
call gitgutter#utility#warn('No previous hunks')
endif
endfunction
" Returns the hunk the cursor is currently in or an empty list if the cursor
" isn't in a hunk.
1 0.000002 function! s:current_hunk() abort
let bufnr = bufnr('')
let current_hunk = []
for hunk in gitgutter#hunk#hunks(bufnr)
if gitgutter#hunk#cursor_in_hunk(hunk)
let current_hunk = hunk
break
endif
endfor
return current_hunk
endfunction
1 0.000002 function! gitgutter#hunk#cursor_in_hunk(hunk) abort
let current_line = line('.')
if current_line == 1 && a:hunk[2] == 0
return 1
endif
if current_line >= a:hunk[2] && current_line < a:hunk[2] + (a:hunk[3] == 0 ? 1 : a:hunk[3])
return 1
endif
return 0
endfunction
1 0.000002 function! gitgutter#hunk#text_object(inner) abort
let hunk = s:current_hunk()
if empty(hunk)
return
endif
let [first_line, last_line] = [hunk[2], hunk[2] + hunk[3] - 1]
if ! a:inner
let lnum = last_line
let eof = line('$')
while lnum < eof && empty(getline(lnum + 1))
let lnum +=1
endwhile
let last_line = lnum
endif
execute 'normal! 'first_line.'GV'.last_line.'G'
endfunction
1 0.000001 function! gitgutter#hunk#stage() abort
call s:hunk_op(function('s:stage'))
silent! call repeat#set("\<Plug>GitGutterStageHunk", -1)<CR>
endfunction
1 0.000002 function! gitgutter#hunk#undo() abort
call s:hunk_op(function('s:undo'))
silent! call repeat#set("\<Plug>GitGutterUndoHunk", -1)<CR>
endfunction
1 0.000001 function! gitgutter#hunk#preview() abort
call s:hunk_op(function('s:preview'))
silent! call repeat#set("\<Plug>GitGutterPreviewHunk", -1)<CR>
endfunction
1 0.000001 function! s:hunk_op(op)
let bufnr = bufnr('')
if gitgutter#utility#is_active(bufnr)
" Get a (synchronous) diff.
let [async, g:gitgutter_async] = [g:gitgutter_async, 0]
let diff = gitgutter#diff#run_diff(bufnr, 1)
let g:gitgutter_async = async
call gitgutter#hunk#set_hunks(bufnr, gitgutter#diff#parse_diff(diff))
if empty(s:current_hunk())
call gitgutter#utility#warn('cursor is not in a hunk')
else
call a:op(gitgutter#diff#hunk_diff(bufnr, diff))
endif
endif
endfunction
1 0.000002 function! s:stage(hunk_diff)
let bufnr = bufnr('')
let diff = s:adjust_header(bufnr, a:hunk_diff)
" Apply patch to index.
call gitgutter#utility#system(
\ gitgutter#utility#cd_cmd(bufnr, g:gitgutter_git_executable.' apply --cached --unidiff-zero - '),
\ diff)
" Refresh gitgutter's view of buffer.
call gitgutter#process_buffer(bufnr, 1)
endfunction
1 0.000001 function! s:undo(hunk_diff)
" Apply reverse patch to buffer.
let hunk = gitgutter#diff#parse_hunk(split(a:hunk_diff, '\n')[4])
let lines = map(split(a:hunk_diff, '\n')[5:], 'v:val[1:]')
let lnum = hunk[2]
let added_only = hunk[1] == 0 && hunk[3] > 0
let removed_only = hunk[1] > 0 && hunk[3] == 0
if removed_only
call append(lnum, lines)
elseif added_only
execute lnum .','. (lnum+len(lines)-1) .'d'
else
call append(lnum-1, lines[0:hunk[1]])
execute (lnum+hunk[1]) .','. (lnum+hunk[1]+hunk[3]) .'d'
endif
endfunction
1 0.000001 function! s:preview(hunk_diff)
let hunk_lines = split(s:discard_header(a:hunk_diff), "\n")
let hunk_lines_length = len(hunk_lines)
let previewheight = min([hunk_lines_length, &previewheight])
silent! wincmd P
if !&previewwindow
noautocmd execute 'bo' previewheight 'new'
set previewwindow
else
execute 'resize' previewheight
endif
setlocal noreadonly modifiable filetype=diff buftype=nofile bufhidden=delete noswapfile
execute "%delete_"
call append(0, hunk_lines)
normal! gg
setlocal readonly nomodifiable
noautocmd wincmd p
endfunction
1 0.000001 function! s:adjust_header(bufnr, hunk_diff)
let filepath = gitgutter#utility#repo_path(a:bufnr, 0)
return s:adjust_hunk_summary(s:fix_file_references(filepath, a:hunk_diff))
endfunction
" Replaces references to temp files with the actual file.
1 0.000007 function! s:fix_file_references(filepath, hunk_diff)
let lines = split(a:hunk_diff, '\n')
let left_prefix = matchstr(lines[2], '[abciow12]').'/'
let right_prefix = matchstr(lines[3], '[abciow12]').'/'
let quote = lines[0][11] == '"' ? '"' : ''
let left_file = quote.left_prefix.a:filepath.quote
let right_file = quote.right_prefix.a:filepath.quote
let lines[0] = 'diff --git '.left_file.' '.right_file
let lines[2] = '--- '.left_file
let lines[3] = '+++ '.right_file
return join(lines, "\n")."\n"
endfunction
1 0.000003 if $VIM_GITGUTTER_TEST
function! gitgutter#hunk#fix_file_references(filepath, hunk_diff)
return s:fix_file_references(a:filepath, a:hunk_diff)
endfunction
endif
1 0.000002 function! s:adjust_hunk_summary(hunk_diff) abort
let line_adjustment = s:line_adjustment_for_current_hunk()
let diff = split(a:hunk_diff, '\n', 1)
let diff[4] = substitute(diff[4], '+\@<=\(\d\+\)', '\=submatch(1)+line_adjustment', '')
return join(diff, "\n")
endfunction
1 0.000006 function! s:discard_header(hunk_diff)
return join(split(a:hunk_diff, '\n', 1)[5:], "\n")
endfunction
" Returns the number of lines the current hunk is offset from where it would
" be if any changes above it in the file didn't exist.
1 0.000001 function! s:line_adjustment_for_current_hunk() abort
let bufnr = bufnr('')
let adj = 0
for hunk in gitgutter#hunk#hunks(bufnr)
if gitgutter#hunk#cursor_in_hunk(hunk)
break
else
let adj += hunk[1] - hunk[3]
endif
endfor
return adj
endfunction
SCRIPT /Users/vonmolal/.vim/bundle/vim-gitgutter/autoload/gitgutter/sign.vim
Sourced 1 time
Total time: 0.000211
Self time: 0.000211
count total (s) self (s)
" Vim doesn't namespace sign ids so every plugin shares the same
" namespace. Sign ids are simply integers so to avoid clashes with other
" signs we guess at a clear run.
"
" Note also we currently never reset s:next_sign_id.
1 0.000003 let s:first_sign_id = 3000
1 0.000002 let s:next_sign_id = s:first_sign_id
1 0.000003 let s:dummy_sign_id = s:first_sign_id - 1
" Remove-all-signs optimisation requires Vim 7.3.596+.
1 0.000004 let s:supports_star = v:version > 703 || (v:version == 703 && has("patch596"))
1 0.000002 function! gitgutter#sign#enable() abort
let old_signs = g:gitgutter_signs
let g:gitgutter_signs = 1
call gitgutter#highlight#define_sign_text_highlights()
if !old_signs && !g:gitgutter_highlight_lines
call gitgutter#all(1)
endif
endfunction
1 0.000008 function! gitgutter#sign#disable() abort
let g:gitgutter_signs = 0
call gitgutter#highlight#define_sign_text_highlights()
if !g:gitgutter_highlight_lines
call gitgutter#sign#clear_signs(bufnr(''))
call gitgutter#sign#remove_dummy_sign(bufnr(''), 0)
endif
endfunction
1 0.000001 function! gitgutter#sign#toggle() abort
if g:gitgutter_signs
call gitgutter#sign#disable()
else
call gitgutter#sign#enable()
endif
endfunction
" Removes gitgutter's signs (excluding dummy sign) from the buffer being processed.
1 0.000002 function! gitgutter#sign#clear_signs(bufnr) abort
call s:find_current_signs(a:bufnr)
let sign_ids = map(values(gitgutter#utility#getbufvar(a:bufnr, 'gitgutter_signs')), 'v:val.id')
call s:remove_signs(a:bufnr, sign_ids, 1)
call gitgutter#utility#setbufvar(a:bufnr, 'gitgutter_signs', {})
endfunction
" Updates gitgutter's signs in the buffer being processed.
"
" modified_lines: list of [<line_number (number)>, <name (string)>]
" where name = 'added|removed|modified|modified_removed'
1 0.000002 function! gitgutter#sign#update_signs(bufnr, modified_lines) abort
call s:find_current_signs(a:bufnr)
let new_gitgutter_signs_line_numbers = map(copy(a:modified_lines), 'v:val[0]')
let obsolete_signs = s:obsolete_gitgutter_signs_to_remove(a:bufnr, new_gitgutter_signs_line_numbers)
let flicker_possible = s:remove_all_old_signs && !empty(a:modified_lines)
if flicker_possible
call s:add_dummy_sign(a:bufnr)
endif
call s:remove_signs(a:bufnr, obsolete_signs, s:remove_all_old_signs)
call s:upsert_new_gitgutter_signs(a:bufnr, a:modified_lines)
if flicker_possible
call gitgutter#sign#remove_dummy_sign(a:bufnr, 0)
endif
endfunction
1 0.000002 function! s:add_dummy_sign(bufnr) abort
if !gitgutter#utility#getbufvar(a:bufnr, 'dummy_sign')
execute "sign place" s:dummy_sign_id "line=" . 9999 "name=GitGutterDummy buffer=" . a:bufnr
call gitgutter#utility#setbufvar(a:bufnr, 'dummy_sign', 1)
endif
endfunction
1 0.000001 function! gitgutter#sign#remove_dummy_sign(bufnr, force) abort
if gitgutter#utility#getbufvar(a:bufnr, 'dummy_sign') && (a:force || !g:gitgutter_sign_column_always)
execute "sign unplace" s:dummy_sign_id "buffer=" . a:bufnr
call gitgutter#utility#setbufvar(a:bufnr, 'dummy_sign', 0)
endif
endfunction
"
" Internal functions
"
1 0.000001 function! s:find_current_signs(bufnr) abort
let gitgutter_signs = {} " <line_number (string)>: {'id': <id (number)>, 'name': <name (string)>}
let other_signs = [] " [<line_number (number),...]
let dummy_sign_placed = 0
redir => signs
silent execute "sign place buffer=" . a:bufnr
redir END
for sign_line in filter(split(signs, '\n')[2:], 'v:val =~# "="')
" Typical sign line: line=88 id=1234 name=GitGutterLineAdded
" We assume splitting is faster than a regexp.
let components = split(sign_line)
let name = split(components[2], '=')[1]
if name =~# 'GitGutterDummy'
let dummy_sign_placed = 1
else
let line_number = str2nr(split(components[0], '=')[1])
if name =~# 'GitGutter'
let id = str2nr(split(components[1], '=')[1])
" Remove orphaned signs (signs placed on lines which have been deleted).
" (When a line is deleted its sign lingers. Subsequent lines' signs'
" line numbers are decremented appropriately.)
if has_key(gitgutter_signs, line_number)
execute "sign unplace" gitgutter_signs[line_number].id
endif
let gitgutter_signs[line_number] = {'id': id, 'name': name}
else
call add(other_signs, line_number)
endif
end
endfor
call gitgutter#utility#setbufvar(a:bufnr, 'dummy_sign', dummy_sign_placed)
call gitgutter#utility#setbufvar(a:bufnr, 'gitgutter_signs', gitgutter_signs)
call gitgutter#utility#setbufvar(a:bufnr, 'other_signs', other_signs)
endfunction
" Returns a list of [<id (number)>, ...]
" Sets `s:remove_all_old_signs` as a side-effect.
1 0.000002 function! s:obsolete_gitgutter_signs_to_remove(bufnr, new_gitgutter_signs_line_numbers) abort
let signs_to_remove = [] " list of [<id (number)>, ...]
let remove_all_signs = 1
let old_gitgutter_signs = gitgutter#utility#getbufvar(a:bufnr, 'gitgutter_signs')
for line_number in keys(old_gitgutter_signs)
if index(a:new_gitgutter_signs_line_numbers, str2nr(line_number)) == -1
call add(signs_to_remove, old_gitgutter_signs[line_number].id)
else
let remove_all_signs = 0
endif
endfor
let s:remove_all_old_signs = remove_all_signs
return signs_to_remove
endfunction
1 0.000003 function! s:remove_signs(bufnr, sign_ids, all_signs) abort
if a:all_signs && s:supports_star && empty(gitgutter#utility#getbufvar(a:bufnr, 'other_signs'))
let dummy_sign_present = gitgutter#utility#getbufvar(a:bufnr, 'dummy_sign')
execute "sign unplace * buffer=" . a:bufnr
if dummy_sign_present
execute "sign place" s:dummy_sign_id "line=" . 9999 "name=GitGutterDummy buffer=" . a:bufnr
endif
else
for id in a:sign_ids
execute "sign unplace" id
endfor
endif
endfunction
1 0.000002 function! s:upsert_new_gitgutter_signs(bufnr, modified_lines) abort
let other_signs = gitgutter#utility#getbufvar(a:bufnr, 'other_signs')
let old_gitgutter_signs = gitgutter#utility#getbufvar(a:bufnr, 'gitgutter_signs')
for line in a:modified_lines
let line_number = line[0] " <number>
if index(other_signs, line_number) == -1 " don't clobber others' signs
let name = s:highlight_name_for_change(line[1])
if !has_key(old_gitgutter_signs, line_number) " insert
let id = s:next_sign_id()
execute "sign place" id "line=" . line_number "name=" . name "buffer=" . a:bufnr
else " update if sign has changed
let old_sign = old_gitgutter_signs[line_number]
if old_sign.name !=# name
execute "sign place" old_sign.id "name=" . name "buffer=" . a:bufnr
end
endif
endif
endfor
" At this point b:gitgutter_gitgutter_signs is out of date.
endfunction
1 0.000002 function! s:next_sign_id() abort
let next_id = s:next_sign_id
let s:next_sign_id += 1
return next_id
endfunction
" Only for testing.
1 0.000001 function! gitgutter#sign#reset()
let s:next_sign_id = s:first_sign_id
endfunction
1 0.000002 function! s:highlight_name_for_change(text) abort
if a:text ==# 'added'
return 'GitGutterLineAdded'
elseif a:text ==# 'removed'
return 'GitGutterLineRemoved'
elseif a:text ==# 'removed_first_line'
return 'GitGutterLineRemovedFirstLine'
elseif a:text ==# 'modified'
return 'GitGutterLineModified'
elseif a:text ==# 'modified_removed'
return 'GitGutterLineModifiedRemoved'
endif
endfunction
FUNCTION <SNR>121_process_modified_and_added()
Called 711 times
Total time: 0.065517
Self time: 0.065517
count total (s) self (s)
711 0.000663 let offset = 0
2840 0.003059 while offset < a:from_count
2129 0.003182 let line_number = a:to_line + offset
2129 0.004963 call add(a:modifications, [line_number, 'modified'])
2129 0.001830 let offset += 1
2129 0.002536 endwhile
7912 0.006587 while offset < a:to_count
7201 0.008854 let line_number = a:to_line + offset
7201 0.014349 call add(a:modifications, [line_number, 'added'])
7201 0.005610 let offset += 1
7201 0.003376 endwhile
FUNCTION <SNR>120_vim_version()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
redir => version_info
silent execute 'version'
redir END
call s:output(split(version_info, '\n')[0:2])
FUNCTION <SNR>119_on_exit_vim()
Called 738 times
Total time: 24.823469
Self time: 0.069613
count total (s) self (s)
738 24.822666 0.068810 call self.handler.out(self.buffer, join(self.stdoutbuffer, "\n"))
FUNCTION <SNR>123_obsolete_gitgutter_signs_to_remove()
Called 736 times
Total time: 0.142010
Self time: 0.136641
count total (s) self (s)
736 0.000903 let signs_to_remove = [] " list of [<id (number)>, ...]
736 0.000819 let remove_all_signs = 1
736 0.008573 0.003204 let old_gitgutter_signs = gitgutter#utility#getbufvar(a:bufnr, 'gitgutter_signs')
15865 0.017729 for line_number in keys(old_gitgutter_signs)
15129 0.040922 if index(a:new_gitgutter_signs_line_numbers, str2nr(line_number)) == -1
1952 0.004037 call add(signs_to_remove, old_gitgutter_signs[line_number].id)
1952 0.000856 else
13177 0.011292 let remove_all_signs = 0
13177 0.006000 endif
15129 0.008823 endfor
736 0.002439 let s:remove_all_old_signs = remove_all_signs
736 0.000816 return signs_to_remove
FUNCTION <SNR>38_match_highlight()
Called 2 times
Total time: 0.000027
Self time: 0.000027
count total (s) self (s)
2 0.000017 let matches = matchlist(a:highlight, a:pattern)
2 0.000004 if len(matches) == 0
return 'NONE'
endif
2 0.000002 return matches[1]
FUNCTION gitgutter#utility#system()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
call gitgutter#debug#log(a:cmd, a:000)
call s:use_known_shell()
silent let output = (a:0 == 0) ? system(a:cmd) : system(a:cmd, a:1)
call s:restore_shell()
return output
FUNCTION gitgutter#hunk#stage()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
call s:hunk_op(function('s:stage'))
silent! call repeat#set("\<Plug>GitGutterStageHunk", -1)<CR>
FUNCTION <SNR>120_option()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
if exists('+' . a:name)
let v = eval('&' . a:name)
call s:output(a:name . '=' . v)
" redir => output
" silent execute "verbose set " . a:name . "?"
" redir END
" call s:output(a:name . '=' . output)
else
call s:output(a:name . ' [n/a]')
end
FUNCTION <SNR>37_strip_trailing_new_line()
Called 2 times
Total time: 0.000038
Self time: 0.000038
count total (s) self (s)
2 0.000036 return substitute(a:line, '\n$', '', '')
FUNCTION <SNR>119_build_command()
Called 738 times
Total time: 0.003320
Self time: 0.003320
count total (s) self (s)
738 0.001349 if has('unix')
738 0.001475 return ['sh', '-c', a:cmd]
endif
if has('win32')
return has('nvim') ? ['cmd.exe', '/c', a:cmd] : 'cmd.exe /c '.a:cmd
endif
throw 'unknown os'
FUNCTION gitgutter#diff#hunk_diff()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let modified_diff = []
let keep_line = 1
" Don't keepempty when splitting because the diff we want may not be the
" final one. Instead add trailing NL at end of function.
for line in split(a:full_diff, '\n')
let hunk_info = gitgutter#diff#parse_hunk(line)
if len(hunk_info) == 4 " start of new hunk
let keep_line = gitgutter#hunk#cursor_in_hunk(hunk_info)
endif
if keep_line
call add(modified_diff, line)
endif
endfor
return join(modified_diff, "\n")."\n"
FUNCTION <SNR>123_find_current_signs()
Called 770 times
Total time: 1.086366
Self time: 1.027893
count total (s) self (s)
770 0.001180 let gitgutter_signs = {} " <line_number (string)>: {'id': <id (number)>, 'name': <name (string)>}
770 0.000881 let other_signs = [] " [<line_number (number),...]
770 0.000859 let dummy_sign_placed = 0
770 0.002003 redir => signs
770 0.014027 silent execute "sign place buffer=" . a:bufnr
770 0.002408 redir END
15899 0.090213 for sign_line in filter(split(signs, '\n')[2:], 'v:val =~# "="')
" Typical sign line: line=88 id=1234 name=GitGutterLineAdded
" We assume splitting is faster than a regexp.
15129 0.397599 let components = split(sign_line)
15129 0.072699 let name = split(components[2], '=')[1]
15129 0.046868 if name =~# 'GitGutterDummy'
let dummy_sign_placed = 1
else
15129 0.071309 let line_number = str2nr(split(components[0], '=')[1])
15129 0.037237 if name =~# 'GitGutter'
15129 0.066770 let id = str2nr(split(components[1], '=')[1])
" Remove orphaned signs (signs placed on lines which have been deleted).
" (When a line is deleted its sign lingers. Subsequent lines' signs'
" line numbers are decremented appropriately.)
15129 0.026185 if has_key(gitgutter_signs, line_number)
execute "sign unplace" gitgutter_signs[line_number].id
endif
15129 0.046771 let gitgutter_signs[line_number] = {'id': id, 'name': name}
15129 0.007378 else
call add(other_signs, line_number)
endif
15129 0.006233 end
15129 0.008755 endfor
770 0.013809 0.004318 call gitgutter#utility#setbufvar(a:bufnr, 'dummy_sign', dummy_sign_placed)
770 0.045222 0.003669 call gitgutter#utility#setbufvar(a:bufnr, 'gitgutter_signs', gitgutter_signs)
770 0.010397 0.002968 call gitgutter#utility#setbufvar(a:bufnr, 'other_signs', other_signs)
FUNCTION gitgutter#highlight#define_signs()
Called 1 time
Total time: 0.000062
Self time: 0.000019
count total (s) self (s)
1 0.000005 sign define GitGutterLineAdded
1 0.000001 sign define GitGutterLineModified
1 0.000001 sign define GitGutterLineRemoved
1 0.000000 sign define GitGutterLineRemovedFirstLine
1 0.000000 sign define GitGutterLineModifiedRemoved
1 0.000001 sign define GitGutterDummy
1 0.000019 0.000003 call s:define_sign_text()
1 0.000019 0.000002 call gitgutter#highlight#define_sign_text_highlights()
1 0.000013 0.000003 call s:define_sign_line_highlights()
FUNCTION <SNR>118_clear()
Called 34 times
Total time: 0.009761
Self time: 0.000546
count total (s) self (s)
34 0.007060 0.000144 call gitgutter#sign#clear_signs(a:bufnr)
34 0.000696 0.000143 call gitgutter#sign#remove_dummy_sign(a:bufnr, 1)
34 0.001367 0.000115 call gitgutter#hunk#reset(a:bufnr)
34 0.000604 0.000110 call s:reset_tick(a:bufnr)
FUNCTION <SNR>121_process_hunk()
Called 3600 times
Total time: 0.498576
Self time: 0.193398
count total (s) self (s)
3600 0.004129 let modifications = []
3600 0.005498 let from_line = a:hunk[0]
3600 0.004664 let from_count = a:hunk[1]
3600 0.004285 let to_line = a:hunk[2]
3600 0.004253 let to_count = a:hunk[3]
3600 0.019743 0.012331 if s:is_added(from_count, to_count)
735 0.037316 0.005623 call s:process_added(modifications, from_count, to_count, to_line)
735 0.047310 0.003645 call gitgutter#hunk#increment_lines_added(a:bufnr, to_count)
735 0.001396 elseif s:is_removed(from_count, to_count)
1 0.000015 0.000006 call s:process_removed(modifications, from_count, to_count, to_line)
1 0.000049 0.000005 call gitgutter#hunk#increment_lines_removed(a:bufnr, from_count)
1 0.000002 elseif s:is_modified(from_count, to_count)
2153 0.041305 0.010224 call s:process_modified(modifications, from_count, to_count, to_line)
2153 0.078221 0.009430 call gitgutter#hunk#increment_lines_modified(a:bufnr, to_count)
2153 0.004025 elseif s:is_modified_and_added(from_count, to_count)
711 0.068751 0.003234 call s:process_modified_and_added(modifications, from_count, to_count, to_line)
711 0.026389 0.002889 call gitgutter#hunk#increment_lines_added(a:bufnr, to_count - from_count)
711 0.023192 0.002633 call gitgutter#hunk#increment_lines_modified(a:bufnr, from_count)
711 0.001349 elseif s:is_modified_and_removed(from_count, to_count)
call s:process_modified_and_removed(modifications, from_count, to_count, to_line)
call gitgutter#hunk#increment_lines_modified(a:bufnr, to_count)
call gitgutter#hunk#increment_lines_removed(a:bufnr, from_count - to_count)
endif
3600 0.003110 return modifications
FUNCTION <SNR>118_uniq()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
return uniq(sort(a:list))
FUNCTION gitgutter#sign#update_signs()
Called 736 times
Total time: 23.213397
Self time: 0.038653
count total (s) self (s)
736 1.088305 0.006042 call s:find_current_signs(a:bufnr)
736 0.011055 let new_gitgutter_signs_line_numbers = map(copy(a:modified_lines), 'v:val[0]')
736 0.146804 0.004794 let obsolete_signs = s:obsolete_gitgutter_signs_to_remove(a:bufnr, new_gitgutter_signs_line_numbers)
736 0.001790 let flicker_possible = s:remove_all_old_signs && !empty(a:modified_lines)
736 0.000594 if flicker_possible
3 0.000122 0.000013 call s:add_dummy_sign(a:bufnr)
3 0.000001 endif
736 20.328798 0.003625 call s:remove_signs(a:bufnr, obsolete_signs, s:remove_all_old_signs)
736 1.628927 0.003857 call s:upsert_new_gitgutter_signs(a:bufnr, a:modified_lines)
736 0.000623 if flicker_possible
3 0.000140 0.000021 call gitgutter#sign#remove_dummy_sign(a:bufnr, 0)
3 0.000002 endif
FUNCTION gitgutter#sign#disable()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let g:gitgutter_signs = 0
call gitgutter#highlight#define_sign_text_highlights()
if !g:gitgutter_highlight_lines
call gitgutter#sign#clear_signs(bufnr(''))
call gitgutter#sign#remove_dummy_sign(bufnr(''), 0)
endif
FUNCTION gitgutter#utility#set_repo_path()
Called 2 times
Total time: 0.003058
Self time: 0.000401
count total (s) self (s)
" Values of path:
" * non-empty string - path
" * -1 - pending
" * -2 - not tracked by git
2 0.000032 0.000006 call gitgutter#utility#setbufvar(a:bufnr, 'path', -1)
2 0.000723 0.000031 let cmd = gitgutter#utility#cd_cmd(a:bufnr, g:gitgutter_git_executable.' ls-files --error-unmatch --full-name '.gitgutter#utility#shellescape(s:filename(a:bufnr)))
2 0.000331 0.000186 if g:gitgutter_async && gitgutter#async#available()
2 0.000005 if has('lambda')
2 0.001906 0.000112 call gitgutter#async#execute(cmd, a:bufnr, { 'out': {bufnr, path -> gitgutter#utility#setbufvar(bufnr, 'path', s:strip_trailing_new_line(path))}, 'err': {bufnr -> gitgutter#utility#setbufvar(bufnr, 'path', -2)}, })
2 0.000005 else
call gitgutter#async#execute(cmd, a:bufnr, { 'out': function('s:set_path'), 'err': function('s:set_path', [-2]) })
endif
2 0.000000 else
let path = gitgutter#utility#system(cmd)
if v:shell_error
call gitgutter#utility#setbufvar(a:bufnr, 'path', -2)
else
call gitgutter#utility#setbufvar(a:bufnr, 'path', s:strip_trailing_new_line(path))
endif
endif
FUNCTION <SNR>37_not_git_dir()
Called 1113 times
Total time: 0.226541
Self time: 0.039602
count total (s) self (s)
1113 0.225925 0.038986 return s:dir(a:bufnr) !~ '[/\\]\.git\($\|[/\\]\)'
FUNCTION gitgutter#hunk#text_object()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let hunk = s:current_hunk()
if empty(hunk)
return
endif
let [first_line, last_line] = [hunk[2], hunk[2] + hunk[3] - 1]
if ! a:inner
let lnum = last_line
let eof = line('$')
while lnum < eof && empty(getline(lnum + 1))
let lnum +=1
endwhile
let last_line = lnum
endif
execute 'normal! 'first_line.'GV'.last_line.'G'
FUNCTION gitgutter#highlight#define_highlights()
Called 1 time
Total time: 0.000204
Self time: 0.000131
count total (s) self (s)
1 0.000078 0.000005 let [guibg, ctermbg] = s:get_background_colors('SignColumn')
" Highlights used by the signs.
1 0.000024 execute "highlight GitGutterAddDefault guifg=#009900 guibg=" . guibg . " ctermfg=2 ctermbg=" . ctermbg
1 0.000013 execute "highlight GitGutterChangeDefault guifg=#bbbb00 guibg=" . guibg . " ctermfg=3 ctermbg=" . ctermbg
1 0.000011 execute "highlight GitGutterDeleteDefault guifg=#ff2222 guibg=" . guibg . " ctermfg=1 ctermbg=" . ctermbg
1 0.000004 highlight default link GitGutterChangeDeleteDefault GitGutterChangeDefault
1 0.000013 execute "highlight GitGutterAddInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
1 0.000015 execute "highlight GitGutterChangeInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
1 0.000012 execute "highlight GitGutterDeleteInvisible guifg=bg guibg=" . guibg . " ctermfg=" . ctermbg . " ctermbg=" . ctermbg
1 0.000004 highlight default link GitGutterChangeDeleteInvisible GitGutterChangeInvisible
1 0.000003 highlight default link GitGutterAdd GitGutterAddDefault
1 0.000002 highlight default link GitGutterChange GitGutterChangeDefault
1 0.000003 highlight default link GitGutterDelete GitGutterDeleteDefault
1 0.000002 highlight default link GitGutterChangeDelete GitGutterChangeDeleteDefault
" Highlights used for the whole line.
1 0.000004 highlight default link GitGutterAddLine DiffAdd
1 0.000005 highlight default link GitGutterChangeLine DiffChange
1 0.000004 highlight default link GitGutterDeleteLine DiffDelete
1 0.000003 highlight default link GitGutterChangeDeleteLine GitGutterChangeLine
FUNCTION gitgutter#hunk#undo()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
call s:hunk_op(function('s:undo'))
silent! call repeat#set("\<Plug>GitGutterUndoHunk", -1)<CR>
FUNCTION gitgutter#process_buffer()
Called 1130 times
Total time: 6.593128
Self time: 0.094258
count total (s) self (s)
" NOTE a:bufnr is not necessarily the current buffer.
1130 0.486046 0.007409 if gitgutter#utility#is_active(a:bufnr)
1096 0.029469 0.008092 if a:force || s:has_fresh_changes(a:bufnr)
736 0.000978 let diff = ''
736 0.000791 try
736 6.028205 0.039110 let diff = gitgutter#diff#run_diff(a:bufnr, 0)
736 0.006240 catch /gitgutter not tracked/
call gitgutter#debug#log('Not tracked: '.gitgutter#utility#file(a:bufnr))
catch /gitgutter diff failed/
call gitgutter#debug#log('Diff failed: '.gitgutter#utility#file(a:bufnr))
call gitgutter#hunk#reset(a:bufnr)
endtry
736 0.001825 if diff != 'async'
call gitgutter#diff#handler(a:bufnr, diff)
endif
736 0.000340 endif
1096 0.000645 else
34 0.009912 0.000151 call s:clear(a:bufnr)
34 0.000017 endif
FUNCTION <SNR>122_hunk_op()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let bufnr = bufnr('')
if gitgutter#utility#is_active(bufnr)
" Get a (synchronous) diff.
let [async, g:gitgutter_async] = [g:gitgutter_async, 0]
let diff = gitgutter#diff#run_diff(bufnr, 1)
let g:gitgutter_async = async
call gitgutter#hunk#set_hunks(bufnr, gitgutter#diff#parse_diff(diff))
if empty(s:current_hunk())
call gitgutter#utility#warn('cursor is not in a hunk')
else
call a:op(gitgutter#diff#hunk_diff(bufnr, diff))
endif
endif
FUNCTION <SNR>122_stage()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let bufnr = bufnr('')
let diff = s:adjust_header(bufnr, a:hunk_diff)
" Apply patch to index.
call gitgutter#utility#system( gitgutter#utility#cd_cmd(bufnr, g:gitgutter_git_executable.' apply --cached --unidiff-zero - '), diff)
" Refresh gitgutter's view of buffer.
call gitgutter#process_buffer(bufnr, 1)
FUNCTION <SNR>119_on_exit_nvim()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
if !a:exit_code
call self.handler.out(self.buffer, join(self.stdoutbuffer, "\n"))
endif
FUNCTION gitgutter#utility#warn()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
echohl WarningMsg
echo 'vim-gitgutter: ' . a:message
echohl None
let v:warningmsg = a:message
FUNCTION <SNR>122_adjust_header()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let filepath = gitgutter#utility#repo_path(a:bufnr, 0)
return s:adjust_hunk_summary(s:fix_file_references(filepath, a:hunk_diff))
FUNCTION <SNR>121_process_added()
Called 735 times
Total time: 0.031693
Self time: 0.031693
count total (s) self (s)
735 0.001728 let offset = 0
4394 0.004651 while offset < a:to_count
3659 0.005727 let line_number = a:to_line + offset
3659 0.008712 call add(a:modifications, [line_number, 'added'])
3659 0.003344 let offset += 1
3659 0.002557 endwhile
FUNCTION <SNR>121_is_modified_and_added()
Called 711 times
Total time: 0.001394
Self time: 0.001394
count total (s) self (s)
711 0.001160 return a:from_count > 0 && a:to_count > 0 && a:from_count < a:to_count
FUNCTION gitgutter#hunk#prev_hunk()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let bufnr = bufnr('')
if gitgutter#utility#is_active(bufnr)
let current_line = line('.')
let hunk_count = 0
for hunk in reverse(copy(gitgutter#hunk#hunks(bufnr)))
if hunk[2] < current_line
let hunk_count += 1
if hunk_count == a:count
let target = hunk[2] == 0 ? 1 : hunk[2]
execute 'normal!' target . 'Gzv'
return
endif
endif
endfor
call gitgutter#utility#warn('No previous hunks')
endif
FUNCTION <SNR>120_format_for_log()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
if type(a:data) == 1
return join(split(a:data,'\n'),"\n")
elseif type(a:data) == 3
return '['.join(a:data,"\n").']'
else
return a:data
endif
FUNCTION <SNR>123_next_sign_id()
Called 1971 times
Total time: 0.006939
Self time: 0.006939
count total (s) self (s)
1971 0.002388 let next_id = s:next_sign_id
1971 0.002328 let s:next_sign_id += 1
1971 0.001396 return next_id
FUNCTION gitgutter#utility#cd_cmd()
Called 738 times
Total time: 0.237031
Self time: 0.016237
count total (s) self (s)
738 0.113065 0.010530 let cd = s:unc_path(a:bufnr) ? 'pushd' : (s:windows() ? 'cd /d' : 'cd')
738 0.123277 0.005018 return cd.' '.s:dir(a:bufnr).' && '.a:cmd
FUNCTION gitgutter#sign#clear_signs()
Called 34 times
Total time: 0.006916
Self time: 0.000819
count total (s) self (s)
34 0.004281 0.000178 call s:find_current_signs(a:bufnr)
34 0.000549 0.000262 let sign_ids = map(values(gitgutter#utility#getbufvar(a:bufnr, 'gitgutter_signs')), 'v:val.id')
34 0.001525 0.000198 call s:remove_signs(a:bufnr, sign_ids, 1)
34 0.000515 0.000135 call gitgutter#utility#setbufvar(a:bufnr, 'gitgutter_signs', {})
FUNCTION <SNR>37_windows()
Called 739 times
Total time: 0.007225
Self time: 0.007225
count total (s) self (s)
739 0.006819 return has('win64') || has('win32') || has('win16')
FUNCTION <SNR>122_line_adjustment_for_current_hunk()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let bufnr = bufnr('')
let adj = 0
for hunk in gitgutter#hunk#hunks(bufnr)
if gitgutter#hunk#cursor_in_hunk(hunk)
break
else
let adj += hunk[1] - hunk[3]
endif
endfor
return adj
FUNCTION GitGutterGetHunks()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let bufnr = bufnr('')
return gitgutter#utility#is_active(bufnr) ? gitgutter#hunk#hunks(bufnr) : []
FUNCTION <SNR>37_set_path()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
if a:bufnr == -2
let [bufnr, path] = [a:path, a:bufnr]
call gitgutter#utility#setbufvar(bufnr, 'path', path)
else
call gitgutter#utility#setbufvar(a:bufnr, 'path', s:strip_trailing_new_line(a:path))
endif
FUNCTION <SNR>120_separator()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
call s:output('')
FUNCTION gitgutter#diff#parse_diff()
Called 736 times
Total time: 0.749815
Self time: 0.271958
count total (s) self (s)
736 0.002325 let hunks = []
26838 0.057163 for line in split(a:diff, '\n')
26102 0.580217 0.102360 let hunk_info = gitgutter#diff#parse_hunk(line)
26102 0.035659 if len(hunk_info) == 4
3600 0.006377 call add(hunks, hunk_info)
3600 0.001843 endif
26102 0.016631 endfor
736 0.000610 return hunks
FUNCTION <SNR>121_is_removed()
Called 2865 times
Total time: 0.005806
Self time: 0.005806
count total (s) self (s)
2865 0.005021 return a:from_count > 0 && a:to_count == 0
FUNCTION gitgutter#enable()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let g:gitgutter_enabled = 1
call gitgutter#all(1)
FUNCTION gitgutter#diff#process_hunks()
Called 736 times
Total time: 0.530202
Self time: 0.031626
count total (s) self (s)
736 0.000961 let modified_lines = []
4336 0.003732 for hunk in a:hunks
3600 0.519055 0.020479 call extend(modified_lines, s:process_hunk(a:bufnr, hunk))
3600 0.002019 endfor
736 0.000614 return modified_lines
FUNCTION <SNR>37_abs_path()
Called 4446 times
Total time: 0.499924
Self time: 0.499924
count total (s) self (s)
4446 0.478458 let p = resolve(expand('#'.a:bufnr.':p'))
4446 0.017915 return a:shellesc ? gitgutter#utility#shellescape(p) : p
FUNCTION <SNR>120_git_version()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let v = system(g:gitgutter_git_executable.' --version')
call s:output( substitute(v, '\n$', '', '') )
FUNCTION <SNR>120_output()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
call append(line('$'), a:text)
FUNCTION gitgutter#debug#log()
Called 1474 times
Total time: 0.050134
Self time: 0.050134
count total (s) self (s)
1474 0.002501 if g:gitgutter_log
if s:new_log_session && gitgutter#async#available()
if exists('*ch_logfile')
call ch_logfile(s:channel_log, 'w')
endif
endif
execute 'redir >> '.s:log_file
if s:new_log_session
let s:start = reltime()
silent echo "\n==== start log session ===="
endif
let elapsed = reltimestr(reltime(s:start)).' '
silent echo ''
" callers excluding this function
silent echo elapsed.expand('<sfile>')[:-22].':'
silent echo elapsed.s:format_for_log(a:message)
if a:0 && !empty(a:1)
for msg in a:000
silent echo elapsed.s:format_for_log(msg)
endfor
endif
redir END
let s:new_log_session = 0
endif
FUNCTION <SNR>122_current_hunk()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let bufnr = bufnr('')
let current_hunk = []
for hunk in gitgutter#hunk#hunks(bufnr)
if gitgutter#hunk#cursor_in_hunk(hunk)
let current_hunk = hunk
break
endif
endfor
return current_hunk
FUNCTION gitgutter#disable()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
" get list of all buffers (across all tabs)
let buflist = []
for i in range(tabpagenr('$'))
call extend(buflist, tabpagebuflist(i + 1))
endfor
for bufnr in s:uniq(buflist)
let file = expand('#'.bufnr.':p')
if !empty(file)
call s:clear(bufnr)
endif
endfor
let g:gitgutter_enabled = 0
FUNCTION gitgutter#utility#extension()
Called 736 times
Total time: 0.081908
Self time: 0.005279
count total (s) self (s)
736 0.081563 0.004934 return fnamemodify(s:abs_path(a:bufnr, 0), ':e')
FUNCTION <SNR>37_winshell()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
return &shell =~? 'cmd' || exists('+shellslash') && !&shellslash
FUNCTION <SNR>119_on_stderr_vim()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
call self.handler.err(self.buffer)
try
call ch_close(a:channel) " so close_cb and its 'out' handler are not triggered
catch /E906/
" noop
endtry
FUNCTION gitgutter#highlight#define_sign_column_highlight()
Called 1 time
Total time: 0.000012
Self time: 0.000012
count total (s) self (s)
1 0.000002 if g:gitgutter_override_sign_column_highlight
highlight! link SignColumn LineNr
else
1 0.000007 highlight default link SignColumn LineNr
1 0.000001 endif
FUNCTION gitgutter#hunk#hunks()
Called 736 times
Total time: 0.013375
Self time: 0.007475
count total (s) self (s)
736 0.011498 0.005598 return gitgutter#utility#getbufvar(a:bufnr, 'hunks', [])
FUNCTION gitgutter#utility#warn_once()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
if empty(gitgutter#utility#getbufvar(a:bufnr, a:key))
call gitgutter#utility#setbufvar(a:bufnr, a:key, '1')
echohl WarningMsg
redraw | echom 'vim-gitgutter: ' . a:message
echohl None
let v:warningmsg = a:message
endif
FUNCTION <SNR>38_define_sign_line_highlights()
Called 1 time
Total time: 0.000010
Self time: 0.000010
count total (s) self (s)
1 0.000001 if g:gitgutter_highlight_lines
sign define GitGutterLineAdded linehl=GitGutterAddLine
sign define GitGutterLineModified linehl=GitGutterChangeLine
sign define GitGutterLineRemoved linehl=GitGutterDeleteLine
sign define GitGutterLineRemovedFirstLine linehl=GitGutterDeleteLine
sign define GitGutterLineModifiedRemoved linehl=GitGutterChangeDeleteLine
else
1 0.000003 sign define GitGutterLineAdded linehl=
1 0.000000 sign define GitGutterLineModified linehl=
1 0.000001 sign define GitGutterLineRemoved linehl=
1 0.000001 sign define GitGutterLineRemovedFirstLine linehl=
1 0.000000 sign define GitGutterLineModifiedRemoved linehl=
1 0.000001 endif
FUNCTION <SNR>37_unc_path()
Called 738 times
Total time: 0.095317
Self time: 0.009944
count total (s) self (s)
738 0.094938 0.009565 return s:abs_path(a:bufnr, 0) =~ '^\\\\'
FUNCTION <SNR>123_upsert_new_gitgutter_signs()
Called 736 times
Total time: 1.625070
Self time: 1.549055
count total (s) self (s)
736 0.008705 0.002992 let other_signs = gitgutter#utility#getbufvar(a:bufnr, 'other_signs')
736 0.007590 0.002843 let old_gitgutter_signs = gitgutter#utility#getbufvar(a:bufnr, 'gitgutter_signs')
15884 0.011564 for line in a:modified_lines
15148 0.019561 let line_number = line[0] " <number>
15148 0.024512 if index(other_signs, line_number) == -1 " don't clobber others' signs
15148 0.116142 0.057526 let name = s:highlight_name_for_change(line[1])
15148 0.027185 if !has_key(old_gitgutter_signs, line_number) " insert
1971 0.013152 0.006213 let id = s:next_sign_id()
1971 0.615093 execute "sign place" id "line=" . line_number "name=" . name "buffer=" . a:bufnr
1971 0.001858 else " update if sign has changed
13177 0.020944 let old_sign = old_gitgutter_signs[line_number]
13177 0.015423 if old_sign.name !=# name
175 0.633639 execute "sign place" old_sign.id "name=" . name "buffer=" . a:bufnr
175 0.000298 end
13177 0.005201 endif
15148 0.006006 endif
15148 0.010925 endfor
" At this point b:gitgutter_gitgutter_signs is out of date.
FUNCTION gitgutter#hunk#increment_lines_modified()
Called 2864 times
Total time: 0.089350
Self time: 0.028069
count total (s) self (s)
2864 0.043190 0.009605 let summary = gitgutter#hunk#summary(a:bufnr)
2864 0.004449 let summary[1] += a:count
2864 0.038051 0.010355 call gitgutter#utility#setbufvar(a:bufnr, 'summary', summary)
FUNCTION gitgutter#sign#remove_dummy_sign()
Called 37 times
Total time: 0.000672
Self time: 0.000361
count total (s) self (s)
37 0.000443 0.000167 if gitgutter#utility#getbufvar(a:bufnr, 'dummy_sign') && (a:force || !g:gitgutter_sign_column_always)
3 0.000018 execute "sign unplace" s:dummy_sign_id "buffer=" . a:bufnr
3 0.000049 0.000014 call gitgutter#utility#setbufvar(a:bufnr, 'dummy_sign', 0)
3 0.000002 endif
FUNCTION gitgutter#hunk#increment_lines_added()
Called 1446 times
Total time: 0.067165
Self time: 0.020215
count total (s) self (s)
1446 0.038519 0.006591 let summary = gitgutter#hunk#summary(a:bufnr)
1446 0.002700 let summary[0] += a:count
1446 0.023054 0.008032 call gitgutter#utility#setbufvar(a:bufnr, 'summary', summary)
FUNCTION <SNR>122_adjust_hunk_summary()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let line_adjustment = s:line_adjustment_for_current_hunk()
let diff = split(a:hunk_diff, '\n', 1)
let diff[4] = substitute(diff[4], '+\@<=\(\d\+\)', '\=submatch(1)+line_adjustment', '')
return join(diff, "\n")
FUNCTION <SNR>118_has_fresh_changes()
Called 1079 times
Total time: 0.021377
Self time: 0.008934
count total (s) self (s)
1079 0.020810 0.008367 return getbufvar(a:bufnr, 'changedtick') != gitgutter#utility#getbufvar(a:bufnr, 'tick')
FUNCTION gitgutter#debug#debug()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
" Open a scratch buffer
vsplit __GitGutter_Debug__
normal! ggdG
setlocal buftype=nofile
setlocal bufhidden=delete
setlocal noswapfile
call s:vim_version()
call s:separator()
call s:git_version()
call s:separator()
call s:grep_version()
call s:separator()
call s:option('updatetime')
call s:option('shell')
call s:option('shellcmdflag')
call s:option('shellpipe')
call s:option('shellquote')
call s:option('shellredir')
call s:option('shellslash')
call s:option('shelltemp')
call s:option('shelltype')
call s:option('shellxescape')
call s:option('shellxquote')
FUNCTION gitgutter#all()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
for bufnr in s:uniq(tabpagebuflist())
let file = expand('#'.bufnr.':p')
if !empty(file)
call gitgutter#init_buffer(bufnr)
call gitgutter#process_buffer(bufnr, a:force)
endif
endfor
FUNCTION <SNR>37_vimdiff()
Called 1113 times
Total time: 0.022585
Self time: 0.022585
count total (s) self (s)
2226 0.006602 for winid in win_findbuf(a:bufnr)
1113 0.004073 if getwinvar(winid, '&diff')
return 1
endif
1113 0.002550 endfor
1113 0.001004 return 0
FUNCTION gitgutter#highlight#line_toggle()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
if g:gitgutter_highlight_lines
call gitgutter#highlight#line_disable()
else
call gitgutter#highlight#line_enable()
endif
FUNCTION <SNR>121_is_added()
Called 3600 times
Total time: 0.007412
Self time: 0.007412
count total (s) self (s)
3600 0.004935 return a:from_count == 0 && a:to_count > 0
FUNCTION gitgutter#utility#shellescape()
Called 2589 times
Total time: 0.117434
Self time: 0.117434
count total (s) self (s)
2589 0.111024 if a:arg =~ '^[A-Za-z0-9_/.-]\+$'
2589 0.004015 return a:arg
elseif s:winshell()
return '"' . substitute(substitute(a:arg, '"', '""', 'g'), '%', '"%"', 'g') . '"'
else
return shellescape(a:arg)
endif
FUNCTION GitGutterGetHunkSummary()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
return gitgutter#hunk#summary(winbufnr(0))
FUNCTION gitgutter#async#available()
Called 738 times
Total time: 0.003163
Self time: 0.003163
count total (s) self (s)
738 0.002762 return s:available
FUNCTION gitgutter#diff#parse_hunk()
Called 26102 times
Total time: 0.477857
Self time: 0.477857
count total (s) self (s)
26102 0.194353 let matches = matchlist(a:line, s:hunk_re)
26102 0.037029 if len(matches) > 0
3600 0.010854 let from_line = str2nr(matches[1])
3600 0.010781 let from_count = (matches[2] == '') ? 1 : str2nr(matches[2])
3600 0.007269 let to_line = str2nr(matches[3])
3600 0.008796 let to_count = (matches[4] == '') ? 1 : str2nr(matches[4])
3600 0.007603 return [from_line, from_count, to_line, to_count]
else
22502 0.014441 return []
end
FUNCTION <SNR>123_add_dummy_sign()
Called 3 times
Total time: 0.000109
Self time: 0.000054
count total (s) self (s)
3 0.000035 0.000011 if !gitgutter#utility#getbufvar(a:bufnr, 'dummy_sign')
3 0.000027 execute "sign place" s:dummy_sign_id "line=" . 9999 "name=GitGutterDummy buffer=" . a:bufnr
3 0.000044 0.000013 call gitgutter#utility#setbufvar(a:bufnr, 'dummy_sign', 1)
3 0.000002 endif
FUNCTION <SNR>122_preview()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let hunk_lines = split(s:discard_header(a:hunk_diff), "\n")
let hunk_lines_length = len(hunk_lines)
let previewheight = min([hunk_lines_length, &previewheight])
silent! wincmd P
if !&previewwindow
noautocmd execute 'bo' previewheight 'new'
set previewwindow
else
execute 'resize' previewheight
endif
setlocal noreadonly modifiable filetype=diff buftype=nofile bufhidden=delete noswapfile
execute "%delete_"
call append(0, hunk_lines)
normal! gg
setlocal readonly nomodifiable
noautocmd wincmd p
FUNCTION <SNR>122_undo()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
" Apply reverse patch to buffer.
let hunk = gitgutter#diff#parse_hunk(split(a:hunk_diff, '\n')[4])
let lines = map(split(a:hunk_diff, '\n')[5:], 'v:val[1:]')
let lnum = hunk[2]
let added_only = hunk[1] == 0 && hunk[3] > 0
let removed_only = hunk[1] > 0 && hunk[3] == 0
if removed_only
call append(lnum, lines)
elseif added_only
execute lnum .','. (lnum+len(lines)-1) .'d'
else
call append(lnum-1, lines[0:hunk[1]])
execute (lnum+hunk[1]) .','. (lnum+hunk[1]+hunk[3]) .'d'
endif
FUNCTION <SNR>121_is_modified_and_removed()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
return a:from_count > 0 && a:to_count > 0 && a:from_count > a:to_count
FUNCTION <SNR>121_process_modified()
Called 2153 times
Total time: 0.031081
Self time: 0.031081
count total (s) self (s)
2153 0.002219 let offset = 0
4311 0.004457 while offset < a:to_count
2158 0.003722 let line_number = a:to_line + offset
2158 0.005530 call add(a:modifications, [line_number, 'modified'])
2158 0.002093 let offset += 1
2158 0.001671 endwhile
FUNCTION gitgutter#diff#handler()
Called 736 times
Total time: 24.753645
Self time: 0.065632
count total (s) self (s)
736 0.038535 0.011550 call gitgutter#debug#log(a:diff)
736 0.905747 0.014407 call gitgutter#hunk#set_hunks(a:bufnr, gitgutter#diff#parse_diff(a:diff))
736 0.549087 0.005510 let modified_lines = gitgutter#diff#process_hunks(a:bufnr, gitgutter#hunk#hunks(a:bufnr))
736 0.002815 let signs_count = len(modified_lines)
736 0.001280 if signs_count > g:gitgutter_max_signs
call gitgutter#utility#warn_once(a:bufnr, printf( 'exceeded maximum number of signs (%d > %d, configured by g:gitgutter_max_signs).', signs_count, g:gitgutter_max_signs), 'max_signs')
call gitgutter#sign#clear_signs(a:bufnr)
else
736 0.001097 if g:gitgutter_signs || g:gitgutter_highlight_lines
736 23.220291 0.006654 call gitgutter#sign#update_signs(a:bufnr, modified_lines)
736 0.000367 endif
736 0.000311 endif
736 0.016609 0.004135 call s:save_last_seen_change(a:bufnr)
736 0.004602 if exists('#User#GitGutter')
let g:gitgutter_hook_context = {'bufnr': a:bufnr}
execute 'doautocmd' s:nomodeline 'User GitGutter'
unlet g:gitgutter_hook_context
endif
FUNCTION <SNR>120_grep_version()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let v = system('grep --version')
call s:output( substitute(v, '\n$', '', '') )
let v = system('grep --help')
call s:output( substitute(v, '\%x00', '', 'g') )
FUNCTION <SNR>121_process_removed()
Called 1 time
Total time: 0.000009
Self time: 0.000009
count total (s) self (s)
1 0.000003 if a:to_line == 0
1 0.000003 call add(a:modifications, [1, 'removed_first_line'])
1 0.000001 else
call add(a:modifications, [a:to_line, 'removed'])
endif
FUNCTION gitgutter#utility#setbufvar()
Called 8975 times
Total time: 0.179136
Self time: 0.179136
count total (s) self (s)
8975 0.060676 let dict = get(getbufvar(a:buffer, ''), 'gitgutter', {})
8975 0.016480 let needs_setting = empty(dict)
8975 0.069024 let dict[a:varname] = a:val
8975 0.007162 if needs_setting
9 0.000028 call setbufvar(a:buffer, 'gitgutter', dict)
9 0.000004 endif
FUNCTION gitgutter#hunk#preview()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
call s:hunk_op(function('s:preview'))
silent! call repeat#set("\<Plug>GitGutterPreviewHunk", -1)<CR>
FUNCTION <SNR>38_define_sign_text()
Called 1 time
Total time: 0.000016
Self time: 0.000016
count total (s) self (s)
1 0.000004 execute "sign define GitGutterLineAdded text=" . g:gitgutter_sign_added
1 0.000003 execute "sign define GitGutterLineModified text=" . g:gitgutter_sign_modified
1 0.000002 execute "sign define GitGutterLineRemoved text=" . g:gitgutter_sign_removed
1 0.000003 execute "sign define GitGutterLineRemovedFirstLine text=" . g:gitgutter_sign_removed_first_line
1 0.000003 execute "sign define GitGutterLineModifiedRemoved text=" . g:gitgutter_sign_modified_removed
FUNCTION <SNR>122_reset_summary()
Called 770 times
Total time: 0.017017
Self time: 0.006995
count total (s) self (s)
770 0.015221 0.005199 call gitgutter#utility#setbufvar(a:bufnr, 'summary', [0,0,0])
FUNCTION <SNR>123_remove_signs()
Called 770 times
Total time: 20.326500
Self time: 20.325883
count total (s) self (s)
770 0.002611 0.002287 if a:all_signs && s:supports_star && empty(gitgutter#utility#getbufvar(a:bufnr, 'other_signs'))
42 0.000464 0.000171 let dummy_sign_present = gitgutter#utility#getbufvar(a:bufnr, 'dummy_sign')
42 0.000175 execute "sign unplace * buffer=" . a:bufnr
42 0.000043 if dummy_sign_present
3 0.125149 execute "sign place" s:dummy_sign_id "line=" . 9999 "name=GitGutterDummy buffer=" . a:bufnr
3 0.000008 endif
42 0.000020 else
2661 0.003302 for id in a:sign_ids
1933 20.182092 execute "sign unplace" id
1933 0.004854 endfor
728 0.000356 endif
FUNCTION <SNR>121_save_last_seen_change()
Called 736 times
Total time: 0.012474
Self time: 0.004366
count total (s) self (s)
736 0.012174 0.004066 call gitgutter#utility#setbufvar(a:bufnr, 'tick', getbufvar(a:bufnr, 'changedtick'))
FUNCTION <SNR>121_write_buffer()
Called 736 times
Total time: 4.702992
Self time: 4.702992
count total (s) self (s)
736 0.038934 let bufcontents = getbufline(a:bufnr, 1, '$')
736 0.003317 if getbufvar(a:bufnr, '&fileformat') ==# 'dos'
call map(bufcontents, 'v:val."\r"')
endif
736 4.657411 call writefile(bufcontents, a:file)
FUNCTION gitgutter#utility#repo_path()
Called 2230 times
Total time: 0.058685
Self time: 0.019583
count total (s) self (s)
2230 0.029389 0.009659 let p = gitgutter#utility#getbufvar(a:bufnr, 'path')
2230 0.028078 0.008706 return a:shellesc ? gitgutter#utility#shellescape(p) : p
FUNCTION gitgutter#sign#enable()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let old_signs = g:gitgutter_signs
let g:gitgutter_signs = 1
call gitgutter#highlight#define_sign_text_highlights()
if !old_signs && !g:gitgutter_highlight_lines
call gitgutter#all(1)
endif
FUNCTION <SNR>119_on_stderr_nvim()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
call self.handler.err(self.buffer)
FUNCTION gitgutter#hunk#cursor_in_hunk()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let current_line = line('.')
if current_line == 1 && a:hunk[2] == 0
return 1
endif
if current_line >= a:hunk[2] && current_line < a:hunk[2] + (a:hunk[3] == 0 ? 1 : a:hunk[3])
return 1
endif
return 0
FUNCTION gitgutter#hunk#summary()
Called 4311 times
Total time: 0.065533
Self time: 0.023968
count total (s) self (s)
4311 0.062103 0.020538 return gitgutter#utility#getbufvar(a:bufnr, 'summary', [0,0,0])
FUNCTION gitgutter#toggle()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
if g:gitgutter_enabled
call gitgutter#disable()
else
call gitgutter#enable()
endif
FUNCTION gitgutter#init_buffer()
Called 28 times
Total time: 0.011145
Self time: 0.000763
count total (s) self (s)
28 0.007319 0.000384 if gitgutter#utility#is_active(a:bufnr)
17 0.000460 0.000071 let p = gitgutter#utility#repo_path(a:bufnr, 0)
17 0.000057 if type(p) != s:t_string || empty(p)
2 0.003102 0.000044 call gitgutter#utility#set_repo_path(a:bufnr)
2 0.000003 endif
17 0.000011 endif
FUNCTION <SNR>119_on_stdout_nvim()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
if empty(self.stdoutbuffer)
let self.stdoutbuffer = a:data
else
let self.stdoutbuffer = self.stdoutbuffer[:-2] + [self.stdoutbuffer[-1] . a:data[0]] + a:data[1:]
endif
FUNCTION <SNR>122_discard_header()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
return join(split(a:hunk_diff, '\n', 1)[5:], "\n")
FUNCTION gitgutter#diff#run_diff()
Called 736 times
Total time: 5.962255
Self time: 0.224059
count total (s) self (s)
741 0.017653 0.005123 while gitgutter#utility#repo_path(a:bufnr, 0) == -1
5 0.030308 0.029914 sleep 5m
5 0.000100 endwhile
736 0.014156 0.003227 if gitgutter#utility#repo_path(a:bufnr, 0) == -2
throw 'gitgutter not tracked'
endif
" Wrap compound commands in parentheses to make Windows happy.
" bash doesn't mind the parentheses.
736 0.000866 let cmd = '('
" Append buffer number to avoid race conditions between writing and reading
" the files when asynchronously processing multiple buffers.
"
" Without the buffer number, index_file would have a race in the shell
" between the second process writing it (with git-show) and the first
" reading it (with git-diff).
736 0.003010 let index_file = s:temp_index.'.'.a:bufnr
" Without the buffer number, buff_file would have a race between the
" second gitgutter#process_buffer() writing the file (synchronously, below)
" and the first gitgutter#process_buffer()'s async job reading it (with
" git-diff).
736 0.002162 let buff_file = s:temp_buffer.'.'.a:bufnr
736 0.085180 0.003272 let extension = gitgutter#utility#extension(a:bufnr)
736 0.001748 if !empty(extension)
736 0.002404 let index_file .= '.'.extension
736 0.001718 let buff_file .= '.'.extension
736 0.000543 endif
" Write file from index to temporary file.
736 0.040267 0.005430 let index_name = g:gitgutter_diff_base.':'.gitgutter#utility#repo_path(a:bufnr, 1)
736 0.004474 let cmd .= g:gitgutter_git_executable.' --no-pager show '.index_name.' > '.index_file.' && '
" Write buffer to temporary file.
" Note: this is synchronous.
736 4.733021 0.030029 call s:write_buffer(a:bufnr, buff_file)
" Call git-diff with the temporary files.
736 0.006793 let cmd .= g:gitgutter_git_executable.' --no-pager'
736 0.001352 if s:c_flag
736 0.001976 let cmd .= ' -c "diff.autorefreshindex=0"'
736 0.001419 let cmd .= ' -c "diff.noprefix=false"'
736 0.001432 let cmd .= ' -c "core.safecrlf=false"'
736 0.000691 endif
736 0.005408 let cmd .= ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args.' -- '.index_file.' '.buff_file
" Pipe git-diff output into grep.
736 0.003090 if !a:preserve_full_diff && !empty(g:gitgutter_grep)
let cmd .= ' | '.g:gitgutter_grep.' '.gitgutter#utility#shellescape('^@@ ')
endif
" grep exits with 1 when no matches are found; git-diff exits with 1 when
" differences are found. However we want to treat non-matches and
" differences as non-erroneous behaviour; so we OR the command with one
" which always exits with success (0).
736 0.001836 let cmd .= ' || exit 0'
736 0.001190 let cmd .= ')'
736 0.243702 0.007154 let cmd = gitgutter#utility#cd_cmd(a:bufnr, cmd)
736 0.007231 0.004071 if g:gitgutter_async && gitgutter#async#available()
736 0.700735 0.045837 call gitgutter#async#execute(cmd, a:bufnr, { 'out': function('gitgutter#diff#handler'), 'err': function('gitgutter#hunk#reset'), })
736 0.004479 return 'async'
else
let diff = gitgutter#utility#system(cmd)
if v:shell_error
call gitgutter#debug#log(diff)
throw 'gitgutter diff failed'
endif
return diff
endif
FUNCTION <SNR>37_exists_file()
Called 1119 times
Total time: 0.203959
Self time: 0.045686
count total (s) self (s)
1119 0.203446 0.045173 return filereadable(s:abs_path(a:bufnr, 0))
FUNCTION <SNR>123_highlight_name_for_change()
Called 15148 times
Total time: 0.058616
Self time: 0.058616
count total (s) self (s)
15148 0.016513 if a:text ==# 'added'
10860 0.009331 return 'GitGutterLineAdded'
elseif a:text ==# 'removed'
return 'GitGutterLineRemoved'
elseif a:text ==# 'removed_first_line'
1 0.000001 return 'GitGutterLineRemovedFirstLine'
elseif a:text ==# 'modified'
4287 0.003751 return 'GitGutterLineModified'
elseif a:text ==# 'modified_removed'
return 'GitGutterLineModifiedRemoved'
endif
FUNCTION <SNR>119_on_stdout_vim()
Called 26104 times
Total time: 0.088690
Self time: 0.088690
count total (s) self (s)
26104 0.080909 call add(self.stdoutbuffer, a:data)
FUNCTION <SNR>122_fix_file_references()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let lines = split(a:hunk_diff, '\n')
let left_prefix = matchstr(lines[2], '[abciow12]').'/'
let right_prefix = matchstr(lines[3], '[abciow12]').'/'
let quote = lines[0][11] == '"' ? '"' : ''
let left_file = quote.left_prefix.a:filepath.quote
let right_file = quote.right_prefix.a:filepath.quote
let lines[0] = 'diff --git '.left_file.' '.right_file
let lines[2] = '--- '.left_file
let lines[3] = '+++ '.right_file
return join(lines, "\n")."\n"
FUNCTION <SNR>36_set()
Called 19 times
Total time: 0.000209
Self time: 0.000209
count total (s) self (s)
19 0.000034 if !exists(a:var)
16 0.000021 if type(a:default)
8 0.000053 execute 'let' a:var '=' string(a:default)
8 0.000005 else
8 0.000030 execute 'let' a:var '=' a:default
8 0.000001 endif
16 0.000009 endif
FUNCTION gitgutter#hunk#increment_lines_removed()
Called 1 time
Total time: 0.000044
Self time: 0.000014
count total (s) self (s)
1 0.000026 0.000006 let summary = gitgutter#hunk#summary(a:bufnr)
1 0.000003 let summary[2] += a:count
1 0.000014 0.000004 call gitgutter#utility#setbufvar(a:bufnr, 'summary', summary)
FUNCTION gitgutter#async#execute()
Called 738 times
Total time: 0.656692
Self time: 0.630064
count total (s) self (s)
738 0.027494 0.004186 call gitgutter#debug#log('[async] '.a:cmd)
738 0.003130 let options = { 'stdoutbuffer': [], 'buffer': a:bufnr, 'handler': a:handler }
738 0.006441 0.003121 let command = s:build_command(a:cmd)
738 0.001923 if has('nvim')
call jobstart(command, extend(options, { 'on_stdout': function('s:on_stdout_nvim'), 'on_stderr': function('s:on_stderr_nvim'), 'on_exit': function('s:on_exit_nvim') }))
else
738 0.601623 call job_start(command, { 'out_cb': function('s:on_stdout_vim', options), 'err_cb': function('s:on_stderr_vim', options), 'close_cb': function('s:on_exit_vim', options) })
738 0.004777 endif
FUNCTION gitgutter#hunk#next_hunk()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let bufnr = bufnr('')
if gitgutter#utility#is_active(bufnr)
let current_line = line('.')
let hunk_count = 0
for hunk in gitgutter#hunk#hunks(bufnr)
if hunk[2] > current_line
let hunk_count += 1
if hunk_count == a:count
execute 'normal!' hunk[2] . 'Gzv'
return
endif
endif
endfor
call gitgutter#utility#warn('No more hunks')
endif
FUNCTION gitgutter#highlight#line_disable()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let g:gitgutter_highlight_lines = 0
call s:define_sign_line_highlights()
if !g:gitgutter_signs
call gitgutter#sign#clear_signs(bufnr(''))
call gitgutter#sign#remove_dummy_sign(bufnr(''), 0)
endif
redraw!
FUNCTION gitgutter#utility#file()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
return s:abs_path(a:bufnr, 1)
FUNCTION gitgutter#hunk#reset()
Called 34 times
Total time: 0.001252
Self time: 0.000320
count total (s) self (s)
34 0.000524 0.000144 call gitgutter#utility#setbufvar(a:bufnr, 'hunks', [])
34 0.000697 0.000145 call s:reset_summary(a:bufnr)
FUNCTION gitgutter#utility#supports_overscore_sign()
Called 1 time
Total time: 0.000015
Self time: 0.000008
count total (s) self (s)
1 0.000011 0.000004 if s:windows()
return &encoding ==? 'utf-8'
else
1 0.000002 return &termencoding ==? &encoding || &termencoding == ''
endif
FUNCTION gitgutter#utility#is_active()
Called 1158 times
Total time: 0.485572
Self time: 0.025135
count total (s) self (s)
1158 0.484586 0.024149 return g:gitgutter_enabled && !pumvisible() && s:is_file_buffer(a:bufnr) && s:exists_file(a:bufnr) && s:not_git_dir(a:bufnr) && !s:vimdiff(a:bufnr)
FUNCTION gitgutter#highlight#line_enable()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let old_highlight_lines = g:gitgutter_highlight_lines
let g:gitgutter_highlight_lines = 1
call s:define_sign_line_highlights()
if !old_highlight_lines && !g:gitgutter_signs
call gitgutter#all(1)
endif
redraw!
FUNCTION <SNR>37_use_known_shell()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
if has('unix') && &shell !=# 'sh'
let [s:shell, s:shellcmdflag, s:shellredir] = [&shell, &shellcmdflag, &shellredir]
let &shell = 'sh'
set shellcmdflag=-c shellredir=>%s\ 2>&1
endif
FUNCTION <SNR>37_dir()
Called 1851 times
Total time: 0.305198
Self time: 0.027687
count total (s) self (s)
1851 0.304161 0.026650 return gitgutter#utility#shellescape(fnamemodify(s:abs_path(a:bufnr, 0), ':h'))
FUNCTION <SNR>37_filename()
Called 2 times
Total time: 0.000174
Self time: 0.000009
count total (s) self (s)
2 0.000174 0.000009 return fnamemodify(s:abs_path(a:bufnr, 0), ':t')
FUNCTION <SNR>37_restore_shell()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
if has('unix') && exists('s:shell')
let [&shell, &shellcmdflag, &shellredir] = [s:shell, s:shellcmdflag, s:shellredir]
endif
FUNCTION <SNR>38_get_background_colors()
Called 1 time
Total time: 0.000073
Self time: 0.000046
count total (s) self (s)
1 0.000003 redir => highlight
1 0.000014 silent execute 'silent highlight ' . a:group
1 0.000002 redir END
1 0.000008 let link_matches = matchlist(highlight, 'links to \(\S\+\)')
1 0.000002 if len(link_matches) > 0 " follow the link
return s:get_background_colors(link_matches[1])
endif
1 0.000020 0.000005 let ctermbg = s:match_highlight(highlight, 'ctermbg=\([0-9A-Za-z]\+\)')
1 0.000017 0.000005 let guibg = s:match_highlight(highlight, 'guibg=\([#0-9A-Za-z]\+\)')
1 0.000002 return [guibg, ctermbg]
FUNCTION gitgutter#sign#toggle()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
if g:gitgutter_signs
call gitgutter#sign#disable()
else
call gitgutter#sign#enable()
endif
FUNCTION gitgutter#sign#reset()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let s:next_sign_id = s:first_sign_id
FUNCTION <SNR>121_is_modified()
Called 2864 times
Total time: 0.005707
Self time: 0.005707
count total (s) self (s)
2864 0.005033 return a:from_count > 0 && a:to_count > 0 && a:from_count == a:to_count
FUNCTION gitgutter#utility#getbufvar()
Called 10722 times
Total time: 0.096671
Self time: 0.096671
count total (s) self (s)
10722 0.052541 let dict = get(getbufvar(a:buffer, ''), 'gitgutter', {})
10722 0.021922 if has_key(dict, a:varname)
10720 0.015106 return dict[a:varname]
else
2 0.000002 if a:0
return a:1
endif
2 0.000002 endif
FUNCTION gitgutter#highlight#define_sign_text_highlights()
Called 1 time
Total time: 0.000017
Self time: 0.000017
count total (s) self (s)
" Once a sign's text attribute has been defined, it cannot be undefined or
" set to an empty value. So to make signs' text disappear (when toggling
" off or disabling) we make them invisible by setting their foreground colours
" to the background's.
1 0.000001 if g:gitgutter_signs
1 0.000003 sign define GitGutterLineAdded texthl=GitGutterAdd
1 0.000002 sign define GitGutterLineModified texthl=GitGutterChange
1 0.000002 sign define GitGutterLineRemoved texthl=GitGutterDelete
1 0.000002 sign define GitGutterLineRemovedFirstLine texthl=GitGutterDelete
1 0.000002 sign define GitGutterLineModifiedRemoved texthl=GitGutterChangeDelete
1 0.000001 else
sign define GitGutterLineAdded texthl=GitGutterAddInvisible
sign define GitGutterLineModified texthl=GitGutterChangeInvisible
sign define GitGutterLineRemoved texthl=GitGutterDeleteInvisible
sign define GitGutterLineRemovedFirstLine texthl=GitGutterDeleteInvisible
sign define GitGutterLineModifiedRemoved texthl=GitGutterChangeDeleteInvisible
endif
FUNCTION <SNR>118_reset_tick()
Called 34 times
Total time: 0.000494
Self time: 0.000134
count total (s) self (s)
34 0.000479 0.000119 call gitgutter#utility#setbufvar(a:bufnr, 'tick', 0)
FUNCTION <SNR>37_is_file_buffer()
Called 1158 times
Total time: 0.007352
Self time: 0.007352
count total (s) self (s)
1158 0.006552 return empty(getbufvar(a:bufnr, '&buftype'))
FUNCTION <SNR>121_git_supports_command_line_config_override()
Called 1 time
Total time: 0.025650
Self time: 0.000376
count total (s) self (s)
1 0.025632 0.000358 call system(g:gitgutter_git_executable.' -c foo.bar=baz --version')
1 0.000011 return !v:shell_error
FUNCTION <SNR>121_process_modified_and_removed()
Called 0 times
Total time: 0.000000
Self time: 0.000000
count total (s) self (s)
let offset = 0
while offset < a:to_count
let line_number = a:to_line + offset
call add(a:modifications, [line_number, 'modified'])
let offset += 1
endwhile
let a:modifications[-1] = [a:to_line + offset - 1, 'modified_removed']
FUNCTION gitgutter#hunk#set_hunks()
Called 736 times
Total time: 0.141123
Self time: 0.066124
count total (s) self (s)
736 0.106744 0.048210 call gitgutter#utility#setbufvar(a:bufnr, 'hunks', a:hunks)
736 0.021340 0.004875 call s:reset_summary(a:bufnr)
FUNCTIONS SORTED ON TOTAL TIME
count total (s) self (s) function
738 24.823469 0.069613 <SNR>119_on_exit_vim()
736 24.753645 0.065632 gitgutter#diff#handler()
736 23.213397 0.038653 gitgutter#sign#update_signs()
770 20.326500 20.325883 <SNR>123_remove_signs()
1130 6.593128 0.094258 gitgutter#process_buffer()
736 5.962255 0.224059 gitgutter#diff#run_diff()
736 4.702992 <SNR>121_write_buffer()
736 1.625070 1.549055 <SNR>123_upsert_new_gitgutter_signs()
770 1.086366 1.027893 <SNR>123_find_current_signs()
736 0.749815 0.271958 gitgutter#diff#parse_diff()
738 0.656692 0.630064 gitgutter#async#execute()
736 0.530202 0.031626 gitgutter#diff#process_hunks()
4446 0.499924 <SNR>37_abs_path()
3600 0.498576 0.193398 <SNR>121_process_hunk()
1158 0.485572 0.025135 gitgutter#utility#is_active()
26102 0.477857 gitgutter#diff#parse_hunk()
1851 0.305198 0.027687 <SNR>37_dir()
738 0.237031 0.016237 gitgutter#utility#cd_cmd()
1113 0.226541 0.039602 <SNR>37_not_git_dir()
1119 0.203959 0.045686 <SNR>37_exists_file()
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
770 20.326500 20.325883 <SNR>123_remove_signs()
736 4.702992 <SNR>121_write_buffer()
736 1.625070 1.549055 <SNR>123_upsert_new_gitgutter_signs()
770 1.086366 1.027893 <SNR>123_find_current_signs()
738 0.656692 0.630064 gitgutter#async#execute()
4446 0.499924 <SNR>37_abs_path()
26102 0.477857 gitgutter#diff#parse_hunk()
736 0.749815 0.271958 gitgutter#diff#parse_diff()
736 5.962255 0.224059 gitgutter#diff#run_diff()
3600 0.498576 0.193398 <SNR>121_process_hunk()
8975 0.179136 gitgutter#utility#setbufvar()
736 0.142010 0.136641 <SNR>123_obsolete_gitgutter_signs_to_remove()
2589 0.117434 gitgutter#utility#shellescape()
10722 0.096671 gitgutter#utility#getbufvar()
1130 6.593128 0.094258 gitgutter#process_buffer()
26104 0.088690 <SNR>119_on_stdout_vim()
738 24.823469 0.069613 <SNR>119_on_exit_vim()
736 0.141123 0.066124 gitgutter#hunk#set_hunks()
736 24.753645 0.065632 gitgutter#diff#handler()
711 0.065517 <SNR>121_process_modified_and_added()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment