Skip to content

Commit e733501

Browse files
brtkwrclaude
andcommitted
fix: always show conversation start and end in preview
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 479e498 commit e733501

1 file changed

Lines changed: 21 additions & 16 deletions

File tree

main.go

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"time"
1616
)
1717

18-
const version = "0.3.0"
18+
const version = "0.3.1"
1919

2020
// Message represents a conversation message
2121
type Message struct {
@@ -385,25 +385,30 @@ func showPreview(line, query string) {
385385
}
386386
}
387387

388-
// Build set of indices to show (matches + 1 context on each side)
388+
// Build set of indices to show
389389
showSet := make(map[int]bool)
390-
if len(matchIndices) > 0 {
391-
for _, idx := range matchIndices {
392-
if idx > 0 {
393-
showSet[idx-1] = true
394-
}
395-
showSet[idx] = true
396-
if idx < len(conv.Messages)-1 {
397-
showSet[idx+1] = true
398-
}
399-
}
400-
} else {
401-
// No matches, show first 6 messages
402-
for i := 0; i < 6 && i < len(conv.Messages); i++ {
390+
391+
// Always show first 2 and last 2 messages
392+
for i := 0; i < 2 && i < len(conv.Messages); i++ {
393+
showSet[i] = true
394+
}
395+
for i := len(conv.Messages) - 2; i < len(conv.Messages); i++ {
396+
if i >= 0 {
403397
showSet[i] = true
404398
}
405399
}
406400

401+
// Add matches with 1 context on each side
402+
for _, idx := range matchIndices {
403+
if idx > 0 {
404+
showSet[idx-1] = true
405+
}
406+
showSet[idx] = true
407+
if idx < len(conv.Messages)-1 {
408+
showSet[idx+1] = true
409+
}
410+
}
411+
407412
// Display messages with gaps
408413
lastShown := -1
409414
for i := 0; i < len(conv.Messages); i++ {
@@ -555,7 +560,7 @@ func main() {
555560
"--no-sort",
556561
"--tabstop=4",
557562
"--preview", fmt.Sprintf("%s --preview {} {q}", self),
558-
"--preview-window=bottom:70%:wrap:+5",
563+
"--preview-window=bottom:70%:wrap",
559564
"--header=Search conversations | Enter to resume, Esc to quit",
560565
"--prompt=Search: ",
561566
"--height=90%",

0 commit comments

Comments
 (0)