aboutsummaryrefslogtreecommitdiff
path: root/autoload/diff/prune.vim
blob: 23796833aa13898796f518f4c6b0a721a8db9c4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
" Undo some diff lines
function! diff#prune#Prune(type) abort

  " Choose appropriate line ranges depending on mode
  if a:type ==# 'v' || a:type ==# 'V' || a:type ==# "\<C-V>"
    let l:range = '''<,''>'
  else
    let l:range = '''[,'']'
  endif

  " Reinstate removals and remove addenda; preserve search pattern
  let l:search_save = @/
  silent execute l:range.'substitute/^-/ /e'
  silent execute l:range.'global/^+/d'
  let @/ = l:search_save

endfunction