The whole point of a finder is to pick something. Today you add accept - the operation that returns the currently selected candidate, the value a user commits to by pressing Enter.
Return the selected candidate, and signal cleanly when there is nothing to accept.
Accept is the finder’s output. Every earlier operation exists to get the right candidate under the cursor; accept is where that candidate leaves the finder and becomes the answer - the path you cd into, the file you open, the branch you check out. It reads the selected result and returns its candidate.
The edge that matters is an empty result list: with nothing matching, there is nothing to accept, so accept must say so rather than index into an empty slice and crash. Returning a value plus an ok flag is the same “missing is its own answer” shape the matcher used back in lesson two - a clean signal the caller can branch on. With movement and accept in place, the finder model is functionally complete; what remains is drawing it and feeding it keystrokes.
// Return the selected candidate plus an ok flag, mirroring the// found-or-not pattern from matching.func (f *Finder) Accept() (string, bool) {if len(f.Results) == 0 { return "", false }return f.Results[f.Selection].Candidate, true}