Skip to content

Commit

Permalink
Minor fixes with filename
Browse files Browse the repository at this point in the history
1. Don't expand `xx` and $(xx) in filename
2. Colorize filename starts with `-` correctly
  • Loading branch information
Aloxaf committed Apr 16, 2020
1 parent 38b182a commit 607a28b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fzf-tab.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ _fzf_tab_colorize() {
local -a reply stat lstat

# fzf-tab-lscolors::match-by $1 lstat follow
zstat -A lstat -L $1
zstat -A lstat -L -- $1
# follow symlink
(( lstat[3] & 0170000 )) && zstat -A stat $1 2>/dev/null
(( lstat[3] & 0170000 )) && zstat -A stat -- $1 2>/dev/null

fzf-tab-lscolors::from-mode "$1" "$lstat[3]" $stat[3]
# fall back to name
Expand All @@ -235,7 +235,7 @@ _fzf_tab_colorize() {
# If this is not a broken symlink
if [[ -e $rsv ]]; then
# fzf-tab-lscolors::match-by $rsv stat
zstat -A stat $rsv
zstat -A stat -- $rsv
fzf-tab-lscolors::from-mode $rsv $stat[3]
# fall back to name
[[ -z $REPLY ]] && fzf-tab-lscolors::from-name $rsv
Expand Down Expand Up @@ -279,7 +279,7 @@ _fzf_tab_get_candidates() {
dsuf='' dpre=''
if (( $+v[isfile] )); then
filepath=${v[IPREFIX]}${v[hpre]}${k#*$'\b'}
filepath=${(Qe)~filepath}
filepath=${(Q)${(e)~filepath}}
if [[ -d $filepath ]]; then
dsuf=/
fi
Expand Down
15 changes: 15 additions & 0 deletions test/fzftab.ztst
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@

comptesteval 'mkdir -p abc/def/hij abc/dfe/hij'
comptest $': ./a/d/h\t'
comptesteval 'rm -rd abc'
0:nested directory
>line: {: ./abc/def/h}{}
>QUERY:{d}
Expand Down Expand Up @@ -184,6 +185,20 @@
>C1:{dir1/}
>C1:{dir2/}

comptesteval 'echo no > called'
comptesteval "touch 'dir\`echo yes > called\`'"
comptest $': d\t'
echo called:$(<called)
comptesteval "rm 'dir\`echo yes > called\`' called"
0:don''t expand file name
>line: {: dir1/}{}
>QUERY:{dir}
>DESCRIPTION:{file}
>C1:{dir1/}
>C1:{dir2/}
>C1:{dir`echo yes > called`}
>called:no

%clean

zmodload -ui zsh/zpty
Expand Down

0 comments on commit 607a28b

Please sign in to comment.