Skip to content
Open
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 copycat.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ set_default_stored_searches() {
local ip_search="$(get_tmux_option "$copycat_ip_search_option" "$default_ip_search_key")"

if stored_search_not_defined "$url_search"; then
tmux set-option -g "${COPYCAT_VAR_PREFIX}_${url_search}" "(https?://|git@|git://|ssh://|ftp://|file:///)[[:alnum:]?=%/_.:,;~@!#$&()*+-]*"
tmux set-option -g "${COPYCAT_VAR_PREFIX}_${url_search}" "(?<=\(|([\x22\x27]))((https?://|git@|git://|ssh://|ftp://|file:///)[\x22\x27[:alnum:]?=%/_.:,;~@!#$&()*+-]*)(?=\)|\1)|(?2)"
fi
if stored_search_not_defined "$file_search"; then
tmux set-option -g "${COPYCAT_VAR_PREFIX}_${file_search}" "(^|^\.|[[:space:]]|[[:space:]]\.|[[:space:]]\.\.|^\.\.)[[:alnum:]~_-]*/[][[:alnum:]_.#$%&+=/@-]*"
tmux set-option -g "${COPYCAT_VAR_PREFIX}_${file_search}" "(^|(?<=[[:space:]]))(\.|\.\.)?[[:alnum:]~_-]*/[][[:alnum:]_.#$%&+=/@-]*"
fi
if stored_search_not_defined "$digit_search"; then
tmux set-option -g "${COPYCAT_VAR_PREFIX}_${digit_search}" "[[:digit:]]+"
Expand Down
2 changes: 1 addition & 1 deletion scripts/copycat_generate_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ reverse_and_create_copycat_file() {
local file=$1
local copycat_file=$2
local grep_pattern=$3
(tac 2>/dev/null || tail -r) < "$file" | grep -oniE "$grep_pattern" > "$copycat_file"
(tac 2>/dev/null || tail -r) < "$file" | grep -oniP "$grep_pattern" > "$copycat_file"
}

delete_old_files() {
Expand Down
18 changes: 9 additions & 9 deletions test/test_file_search.exp
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@ assert_highlighted "/this/is/some/file.txt" "middle of the pane, absolute path,

display_text "random /this/is/some/file.txt"
tmux_ctrl_f
assert_highlighted " /this/is/some/file.txt" "middle of the pane, absolute path, not beginning of the line"
assert_highlighted "/this/is/some/file.txt" "middle of the pane, absolute path, not beginning of the line"

display_text "another/file.txt"
tmux_ctrl_f
assert_highlighted "another/file.txt" "middle of the pane, relative path, beginning of the line"

display_text "some text another/file.txt"
tmux_ctrl_f
assert_highlighted " another/file.txt" "middle of the pane, relative path, not beginning of the line"
assert_highlighted "another/file.txt" "middle of the pane, relative path, not beginning of the line"

create_output
sleep 0.2
send " some/file.xyz "
sleep 0.2
tmux_ctrl_f
assert_highlighted " some/file.xyz" "middle of the pane relative path, pane bottom"
assert_highlighted "some/file.xyz" "middle of the pane relative path, pane bottom"

# match selection when line contains escaped chars
#-------------------------------------------------
new_tmux_pane
display_text "filename=test.csv\r\nContent-Type: text/csv\r\n"
tmux_ctrl_f
assert_highlighted " text/csv" "match selection when line contains escaped chars"
assert_highlighted "text/csv" "match selection when line contains escaped chars"

# result navigation
#------------------
Expand All @@ -67,7 +67,7 @@ next_match
# /file/1.txt
previous_match
# /file/2.txt
assert_highlighted " /file/2.txt" "result navigation at the top of the pane"
assert_highlighted "/file/2.txt" "result navigation at the top of the pane"

create_output
display_text "/file/1.txt"
Expand All @@ -80,7 +80,7 @@ next_match
# /file/1.txt
previous_match
# /file/2.txt
assert_highlighted " /file/2.txt" "result navigation, middle of the pane"
assert_highlighted "/file/2.txt" "result navigation, middle of the pane"

# 2 matches on the same line
#---------------------------
Expand All @@ -92,7 +92,7 @@ assert_highlighted "/file/1.txt" "2 matches on the same line, first match"
display_text "/file/1.txt another/file/2.txt"
tmux_ctrl_f
next_match
assert_highlighted " another/file/2.txt" "2 matches on the same line, second match"
assert_highlighted "another/file/2.txt" "2 matches on the same line, second match"

# no match, first and last match
#-------------------------------
Expand Down Expand Up @@ -130,15 +130,15 @@ exit_irb
enter_irb
irb_display_text "some text file/within/irb.rb"
tmux_ctrl_f
irb_assert_highlighted " file/within/irb.rb" "irb console relative path, not beggining of line"
irb_assert_highlighted "file/within/irb.rb" "irb console relative path, not beggining of line"
exit_irb

enter_irb
irb_generate_output
send "puts /absolute/file/irb.rb"
sleep 5
tmux_ctrl_f
irb_assert_highlighted " /absolute/file/irb.rb" "irb console absolute path, pane bottom, not beggining of line"
irb_assert_highlighted "/absolute/file/irb.rb" "irb console absolute path, pane bottom, not beggining of line"
exit_irb

# quit
Expand Down