Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/36 #38

Merged
merged 2 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/fzf-obc/core-functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ __fzf_obc_move_hidden_files_last() {
__fzf_obc_move_hidden_files_first() {
# shellcheck disable=SC2154
if ((current_filedir_colors));then
sed -z -r '/^(\x1B\[([0-9]{1,}(;[0-9]{1,})?(;[0-9]{1,})?)?[mGK])(.*\/\.|\.)/!H;//p;$!d;g;s/\x0//'
sed -z -r '/^(\x1B\[([0-9]{1,}(;[0-9]{1,})?(;[0-9]{1,})?)?[mGK])(.*\/\.|\.)/!H;//p;$!d;g;s/\x0//p;d'
else
sed -z -r '/^(.*\/\.|\.)/!H;//p;$!d;g;s/\x0//'
sed -z -r '/^(.*\/\.|\.)/!H;//p;$!d;g;s/\x0//p;d'
fi
}

Expand Down
82 changes: 82 additions & 0 deletions test/spec/test_options.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
class FzfObcTest
def test_options

create_files_dirs(
dest: "#{temp_test_dir}",
subdirs: %w{.d1},
files: %w{
yyy
xxx
.a3
.l1
.p1
.p2
}
)

for short_filedir in (0..1).reverse_each do

if short_filedir == 1
start_dir = ""
else
@tty.send_keys("FZF_OBC_SHORT_FILEDIR=0","#{ENTER}")
@tty.clear_screen()
start_dir = "#{temp_test_dir}/"
end

# default display
@tty.send_keys("cat #{temp_test_dir}/","#{TAB}", delay: 0.01)
@tty.assert_matches <<~TTY
$ cat #{temp_test_dir}/
>
7/7
> #{start_dir}xxx
#{start_dir}yyy
#{start_dir}.a3
#{start_dir}.d1/
#{start_dir}.l1
#{start_dir}.p1
#{start_dir}.p2
TTY
@tty.send_keys("#{CTRLC}")
@tty.clear_screen()

@tty.send_keys("cat #{temp_test_dir}/.a","#{TAB}", delay: 0.01)
@tty.assert_matches <<~TTY
$ cat #{temp_test_dir}/.a3
TTY
@tty.clear_screen()

# hidden first display
@tty.send_keys("FZF_OBC_STD_FILEDIR_HIDDEN_FIRST=1","#{ENTER}")
@tty.clear_screen()

@tty.send_keys("cat #{temp_test_dir}/","#{TAB}", delay: 0.01)
@tty.assert_matches <<~TTY
$ cat #{temp_test_dir}/
>
7/7
> #{start_dir}.a3
#{start_dir}.d1/
#{start_dir}.l1
#{start_dir}.p1
#{start_dir}.p2
#{start_dir}xxx
#{start_dir}yyy
TTY
@tty.send_keys("#{CTRLC}")
@tty.clear_screen()

@tty.send_keys("cat #{temp_test_dir}/.a","#{TAB}", delay: 0.01)
@tty.assert_matches <<~TTY
$ cat #{temp_test_dir}/.a3
TTY
@tty.clear_screen()

# clear the option
@tty.send_keys("unset FZF_OBC_STD_FILEDIR_HIDDEN_FIRST","#{ENTER}")
@tty.clear_screen()

end
end
end