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

[Search Git Status] use box drawing chars for staged/unstaged header #291

Merged
merged 1 commit into from
Jan 25, 2023
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
16 changes: 9 additions & 7 deletions functions/_fzf_report_diff_type.fish
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# helper for _fzf_preview_changed_file
# prints out something like
# +--------+
# | Staged |
# +--------+
# ╭────────╮
# Staged
# ╰────────╯
function _fzf_report_diff_type --argument-names diff_type --description "Print a distinct colored header meant to preface a git patch."
# number of "-" to draw is the length of the string to box + 2 for padding
set repeat_count (math 2 + (string length $diff_type))
set horizontal_border +(string repeat --count $repeat_count -)+
set line (string repeat --count $repeat_count ─)
set top_border ╭$line
set btm_border ╰$line

set_color yellow
echo $horizontal_border
echo "| $diff_type |"
echo $horizontal_border
echo $top_border
echo " $diff_type "
echo $btm_border
set_color normal
end
2 changes: 1 addition & 1 deletion tests/preview_changed_file/deleted_in_working.fish
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mock git diff "echo \$argv"
set output (_fzf_preview_changed_file " D out.log")

contains "| Unstaged |" $output && not contains "| Staged |" $output
contains " Unstaged " $output && not contains " Staged " $output
@test "only shows unstaged changes if file was only deleted in working tree" $status -eq 0
2 changes: 1 addition & 1 deletion tests/preview_changed_file/merge_conflict.fish
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mock git diff "echo \$argv"
set output (_fzf_preview_changed_file "UU out.log")

@test "shows merge conflicts as unmerged" $output[2] = "| Unmerged |"
@test "shows merge conflicts as unmerged" $output[2] = " Unmerged "
2 changes: 1 addition & 1 deletion tests/preview_changed_file/modified_in_both.fish
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mock git diff "echo \$argv"
set output (_fzf_preview_changed_file "MM dir/file.txt")

contains "| Unstaged |" $output && contains "| Staged |" $output
contains " Unstaged " $output && contains " Staged " $output
@test "shows staged and unstaged changes if the file is modified in both places" $status -eq 0