[fzf-tmux/vim/nvim] Do not split small window
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Close #699
authored by Junegunn Choi · committed by Junegunn Choi · parent 60112de · Browse files · 2 files·+21 added−18 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+21 added−18 removed
- other:+21 added−18 removed
Provenance
- Commit
053af9a- Tree
e1a300b- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
60112de
2 files changed+21 added−18 removed
modified:bin/fzf-tmux+3 added-2 removed
15 unmodified lines16 swap=""17 close=""18 term=""19 [[ -n "$LINES" ]] && lines=$LINES || lines=$(tput lines)20+[[ -n "$COLUMNS" ]] && columns=$COLUMNS || columns=$(tput cols)21 22 help() {23 >&2 echo 'usage: fzf-tmux [-u|-d [HEIGHT[%]]] [-l|-r [WIDTH[%]]] [--] [FZF OPTIONS]24 58 unmodified lines83 fi84 else85 if [[ -n "$swap" ]]; then86 if [[ "$arg" =~ ^.l ]]; then86- [[ -n "$COLUMNS" ]] && max=$COLUMNS || max=$(tput cols)87+ max=$columns88 else89 max=$lines90 fi91 size=$(( max - size ))16 unmodified lines108 esac109 [[ -n "$skip" ]] && args+=("$arg")110 done111 111-if [[ -z "$TMUX" ]] || [[ "$lines" -le 15 ]]; then112+if [[ -z "$TMUX" ]] || [[ "$opt" =~ ^-h ]] && [[ "$columns" -le 40 ]] || [[ ! "$opt" =~ ^-h ]] && [[ "$lines" -le 15 ]]; then113 "$fzf" "${args[@]}"114 exit $?115 fi116 64 unmodified linesmodified:plugin/fzf.vim+18 added-16 removed
287 unmodified lines288 \ &lines, &columns, s:shellesc(s:fzf_tmux), size, (has_key(a:dict, 'source') ? '' : '-'))289 endfunction290 291 function! s:splittable(dict)292- return s:present(a:dict, 'up', 'down', 'left', 'right')292+ return s:present(a:dict, 'up', 'down') && &lines > 15 ||293+ \ s:present(a:dict, 'left', 'right') && &columns > 40294 endfunction295 296 function! s:pushd(dict)297 if s:present(a:dict, 'dir')107 unmodified lines405 \ 'left': ['vertical topleft', 'vertical resize', &columns],406 \ 'right': ['vertical botright', 'vertical resize', &columns] }407 let ppos = s:getpos()408 try408- for [dir, triple] in items(directions)409- let val = get(a:dict, dir, '')410- if !empty(val)411- let [cmd, resz, max] = triple412- if (dir == 'up' || dir == 'down') && val[0] == '~'413- let sz = s:calc_size(max, val, a:dict)414- else415- let sz = s:calc_size(max, val, {})416- endif417- execute cmd sz.'new'418- execute resz sz419- return [ppos, {}]420- endif421- endfor409 if s:present(a:dict, 'window')410 execute a:dict.window424- else411+ elseif !s:splittable(a:dict)412 execute (tabpagenr()-1).'tabnew'413+ else414+ for [dir, triple] in items(directions)415+ let val = get(a:dict, dir, '')416+ if !empty(val)417+ let [cmd, resz, max] = triple418+ if (dir == 'up' || dir == 'down') && val[0] == '~'419+ let sz = s:calc_size(max, val, a:dict)420+ else421+ let sz = s:calc_size(max, val, {})422+ endif423+ execute cmd sz.'new'424+ execute resz sz425+ return [ppos, {}]426+ endif427+ endfor428 endif429 return [ppos, { '&l:wfw': &l:wfw, '&l:wfh': &l:wfh }]430 finally431 setlocal winfixwidth winfixheight146 unmodified lines