Skip to content

Commit 3c0a1fd

Browse files
committed
refactor(lib): remove score from header picker and add | after rank
1 parent 0d59d5b commit 3c0a1fd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

spec/cfme_spec.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Describe 'cfme'
2828
End
2929

3030
Mock fzf
31-
echo "header: 1 entry header"
31+
echo "1 | 1 entry header"
3232
End
3333

3434
Mock mock_editor

src/lib/pick_from_headers.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ pick_from_headers() {
2626
# Add a final marker to ensure the last message is captured correctly
2727
echo "=== END ===" >>"$temp_file"
2828

29-
selected_line=$(printf '%s\n' "${headers_ref[@]}" | sort -rn | nl -w1 -s' ' | fzf --ansi \
29+
selected_line=$(printf '%s\n' "${headers_ref[@]}" | sort -rn | sed 's/^[0-9]* //' | nl -w1 -s' | ' | fzf --ansi \
3030
--prompt="Select commit message: " \
31-
--preview "sed -n '/=== MESSAGE {1} ===/,/=== MESSAGE/p' '$temp_file' | head -n -1 | tail -n +2" \
31+
--preview "num=\$(echo {} | grep -o '^[0-9]*'); sed -n \"/=== MESSAGE \$num ===/,/=== MESSAGE/p\" '$temp_file' | head -n -1 | tail -n +2" \
3232
--preview-window=wrap)
3333

3434
local exit_code=$?
@@ -39,6 +39,6 @@ pick_from_headers() {
3939
return 1
4040
}
4141

42-
# Remove the line number and score prefix
43-
echo "${selected_line#* }" | sed 's/^[0-9]* //'
42+
# Remove the rank number and separator
43+
echo "${selected_line}" | sed 's/^[0-9]* | //'
4444
}

0 commit comments

Comments
 (0)