@@ -687,18 +687,30 @@ function! s:bufopen(lines)
687
687
if len (a: lines ) < 2
688
688
return
689
689
endif
690
- let b = matchstr (a: lines [1 ], ' \[\zs[0-9]*\ze\]' )
691
- if empty (a: lines [0 ]) && get (g: , ' fzf_buffers_jump' )
690
+
691
+ let key = a: lines [0 ]
692
+ let buffer_numbers = map (a: lines [1 :], {_idx, bufline - > matchstr (bufline, ' \[\zs[0-9]*\ze\]' )})
693
+
694
+ if key == ' ctrl-d'
695
+ execute ' bdelete' join (buffer_numbers, ' ' )
696
+ return
697
+ endif
698
+
699
+ let b = buffer_numbers[0 ]
700
+
701
+ if empty (key ) && get (g: , ' fzf_buffers_jump' )
692
702
let [t , w ] = s: find_open_window (b )
693
703
if t
694
704
call s: jump (t , w )
695
705
return
696
706
endif
697
707
endif
698
- let cmd = s: action_for (a: lines [0 ])
708
+
709
+ let cmd = s: action_for (key )
699
710
if ! empty (cmd)
700
711
execute ' silent' cmd
701
712
endif
713
+
702
714
execute ' buffer' b
703
715
endfunction
704
716
@@ -728,13 +740,17 @@ endfunction
728
740
function ! fzf#vim#buffers (... )
729
741
let [query, args ] = (a: 0 && type (a: 1 ) == type (' ' )) ?
730
742
\ [a: 1 , a: 000 [1 :]] : [' ' , a: 000 ]
743
+
744
+ let expected_keys = ' ctrl-d,' . join (keys (s: default_action ), ' ,' )
745
+ let ctrl_d_header = [" \t\t :: Press " .s: magenta (' CTRL-D' , ' Special' )." to delete" ]
731
746
let sorted = fzf#vim#_buflisted_sorted ()
732
- let header_lines = ' --header-lines=' . (bufnr (' ' ) == get (sorted, 0 , 0 ) ? 1 : 0 )
747
+ let header_lines = ' --header-lines=' . (bufnr (' ' ) == get (sorted, 0 , 0 ) ? 2 : 1 )
733
748
let tabstop = len (sorted) >= 1000 ? 9 : 8
749
+
734
750
return s: fzf (' buffers' , {
735
- \ ' source' : map (sorted, ' fzf#vim#_format_buffer(v:val)' ),
751
+ \ ' source' : ctrl_d_header + map (sorted, ' fzf#vim#_format_buffer(v:val)' ),
736
752
\ ' sink*' : s: function (' s:bufopen' ),
737
- \ ' options' : [' +m' , ' -x' , ' --tiebreak=index' , header_lines, ' --ansi' , ' -d' , ' \t' , ' --with-nth' , ' 3..' , ' -n' , ' 2,1..2' , ' --prompt' , ' Buf> ' , ' --query' , query, ' --preview-window' , ' +{2}-/2' , ' --tabstop' , tabstop ]
753
+ \ ' options' : [' +m' , ' -x' , ' --tiebreak=index' , header_lines, ' --ansi' , ' -d' , ' \t' , ' --with-nth' , ' 3..' , ' -n' , ' 2,1..2' , ' --prompt' , ' Buf> ' , ' --query' , query, ' --preview-window' , ' +{2}-/2' , ' --tabstop' , tabstop , ' -m ' , ' --expect ' , expected_keys ]
738
754
\} , args )
739
755
endfunction
740
756
0 commit comments