mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-02-27 20:12:29 +08:00
Do not put --layout=reverse-list if FZF_DEFAULT_OPTS sets reverse layout
Close #916
This commit is contained in:
@@ -115,6 +115,14 @@ function! s:remove_layout(opts)
|
|||||||
return a:opts
|
return a:opts
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:reverse_list(opts)
|
||||||
|
let tokens = map(split($FZF_DEFAULT_OPTS, '[^a-z-]'), 'substitute(v:val, "^--", "", "")')
|
||||||
|
if index(tokens, 'reverse') < 0
|
||||||
|
return extend(['--layout=reverse-list'], a:opts)
|
||||||
|
endif
|
||||||
|
return a:opts
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:wrap(name, opts, bang)
|
function! s:wrap(name, opts, bang)
|
||||||
" fzf#wrap does not append --expect if sink or sink* is found
|
" fzf#wrap does not append --expect if sink or sink* is found
|
||||||
let opts = copy(a:opts)
|
let opts = copy(a:opts)
|
||||||
@@ -377,7 +385,7 @@ function! fzf#vim#lines(...)
|
|||||||
return s:fzf('lines', {
|
return s:fzf('lines', {
|
||||||
\ 'source': lines,
|
\ 'source': lines,
|
||||||
\ 'sink*': s:function('s:line_handler'),
|
\ 'sink*': s:function('s:line_handler'),
|
||||||
\ 'options': ['+m', '--tiebreak=index', '--prompt', 'Lines> ', '--ansi', '--extended', '--nth='.nth.'..', '--layout=reverse-list', '--tabstop=1', '--query', query]
|
\ 'options': s:reverse_list(['+m', '--tiebreak=index', '--prompt', 'Lines> ', '--ansi', '--extended', '--nth='.nth.'..', '--tabstop=1', '--query', query])
|
||||||
\}, args)
|
\}, args)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -422,7 +430,7 @@ function! fzf#vim#buffer_lines(...)
|
|||||||
return s:fzf('blines', {
|
return s:fzf('blines', {
|
||||||
\ 'source': s:buffer_lines(query),
|
\ 'source': s:buffer_lines(query),
|
||||||
\ 'sink*': s:function('s:buffer_line_handler'),
|
\ 'sink*': s:function('s:buffer_line_handler'),
|
||||||
\ 'options': ['+m', '--tiebreak=index', '--multi', '--prompt', 'BLines> ', '--ansi', '--extended', '--nth=2..', '--layout=reverse-list', '--tabstop=1']
|
\ 'options': s:reverse_list(['+m', '--tiebreak=index', '--multi', '--prompt', 'BLines> ', '--ansi', '--extended', '--nth=2..', '--tabstop=1'])
|
||||||
\}, args)
|
\}, args)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -782,7 +790,7 @@ function! fzf#vim#buffer_tags(query, ...)
|
|||||||
return s:fzf('btags', {
|
return s:fzf('btags', {
|
||||||
\ 'source': s:btags_source(tag_cmds),
|
\ 'source': s:btags_source(tag_cmds),
|
||||||
\ 'sink*': s:function('s:btags_sink'),
|
\ 'sink*': s:function('s:btags_sink'),
|
||||||
\ 'options': ['--layout=reverse-list', '-m', '-d', '\t', '--with-nth', '1,4..', '-n', '1', '--prompt', 'BTags> ', '--query', a:query]}, args)
|
\ 'options': s:reverse_list(['-m', '-d', '\t', '--with-nth', '1,4..', '-n', '1', '--prompt', 'BTags> ', '--query', a:query])}, args)
|
||||||
catch
|
catch
|
||||||
return s:warn(v:exception)
|
return s:warn(v:exception)
|
||||||
endtry
|
endtry
|
||||||
@@ -1127,10 +1135,10 @@ function! s:commits(buffer_local, args)
|
|||||||
let options = {
|
let options = {
|
||||||
\ 'source': source,
|
\ 'source': source,
|
||||||
\ 'sink*': s:function('s:commits_sink'),
|
\ 'sink*': s:function('s:commits_sink'),
|
||||||
\ 'options': ['--ansi', '--multi', '--tiebreak=index', '--layout=reverse-list',
|
\ 'options': s:reverse_list(['--ansi', '--multi', '--tiebreak=index',
|
||||||
\ '--inline-info', '--prompt', command.'> ', '--bind=ctrl-s:toggle-sort',
|
\ '--inline-info', '--prompt', command.'> ', '--bind=ctrl-s:toggle-sort',
|
||||||
\ '--header', ':: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort, '.s:magenta('CTRL-Y', 'Special').' to yank commit hashes',
|
\ '--header', ':: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort, '.s:magenta('CTRL-Y', 'Special').' to yank commit hashes',
|
||||||
\ '--expect=ctrl-y,'.expect_keys]
|
\ '--expect=ctrl-y,'.expect_keys])
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
if a:buffer_local
|
if a:buffer_local
|
||||||
|
|||||||
Reference in New Issue
Block a user