Documentation
¶
Overview ¶
Package panesearch is the pair of search surfaces a document pane can open on itself: the fuzzy file finder (ctrl+p) and the project-wide ripgrep search (f). Both are rooted at the pane's own directory, which is what makes them work unchanged in the project workspace and in the global Workspaces browser — a pane carries the workspace or shell directory it was opened against, and neither surface asks anything else about the host.
It lives here rather than in one host for the reason the pane frame does: a capability that exists on one pane surface and not the other is the bug the parity rule forbids. The host owns only where the surface is drawn and what happens to the file it picks.
Index ¶
- Constants
- type Caches
- type Kind
- type Mode
- func (m *Mode) Close()
- func (m *Mode) Finder() *filefind.Finder
- func (m *Mode) HandleKey(msg tea.KeyPressMsg) (Outcome, tea.Cmd)
- func (m *Mode) HandleMouse(msg tea.MouseMsg, handler *mouse.Handler) (Outcome, tea.Cmd)
- func (m *Mode) HeaderLabel() string
- func (m *Mode) Kind() Kind
- func (m *Mode) Name() string
- func (m *Mode) Query() string
- func (m *Mode) Search() *projectsearch.Search
- func (m *Mode) SetRecent(paths []string)
- func (m *Mode) SetSize(width, height int)
- func (m *Mode) Update(msg tea.Msg) tea.Cmd
- func (m *Mode) View(width, height int, fill bool, handler *mouse.Handler) string
- type Outcome
Constants ¶
const CacheTTL = filefind.DefaultMaxAge
CacheTTL is how long a root's file list is trusted without a rescan.
The pane surfaces have no filesystem signal, so there is nothing here to invalidate a list precisely; the cache ages itself out instead, on the same clock every finder uses (see filefind.DefaultMaxAge).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Caches ¶
type Caches struct {
// contains filtered or unexported fields
}
Caches holds one file list per root, shared by every pane rooted there. Panes on one root are looking at one directory tree, so they walk it once between them rather than once per ctrl+p: a fresh cache per open meant every open paid a full ScanPaths walk (up to 50k files), and open/esc/open spawned walks whose results were then thrown away.
The zero value is ready to use.
func (*Caches) For ¶
For returns the file list for root. The cache rescans itself on its next Ensure once its last walk has aged out.
type Mode ¶
type Mode struct {
// contains filtered or unexported fields
}
Mode is one pane's live search surface. Exactly one of finder and search is set; the host talks to it through the small vocabulary below so neither the key path nor the render path asks which surface it is driving.
func NewFinder ¶
NewFinder opens the fuzzy file finder rooted at root, reusing (and dating) the caller's per-root file-list cache. The command it returns is the scan, if one was needed; hosts wrap it so its reply comes back to the right pane.
func NewProject ¶
NewProject opens the ripgrep project search rooted at root.
func (*Mode) Close ¶
func (m *Mode) Close()
Close releases whatever the surface still owns. The project search owns a running ripgrep process, which would otherwise keep going to its timeout. The finder's file list belongs to the caller's per-root cache, but the scan it may have in flight is its own: hosts route a landed scan to the mode that issued it and drop one whose mode is gone, and a dropped scan would leave the shared cache marked Scanning for the rest of the session.
func (*Mode) Finder ¶
Finder is the live file finder, or nil when this is a project search. Hosts use it to ask the surface what it is showing; the routing above needs no such question.
func (*Mode) HandleMouse ¶
func (*Mode) HeaderLabel ¶
HeaderLabel is the mode's identity in the pane header: the surface's name and the query so far, so a pane in search mode never reads as a pane showing a file.
func (*Mode) Search ¶
func (m *Mode) Search() *projectsearch.Search
Search is the live project search, or nil when this is a finder.
func (*Mode) SetRecent ¶ added in v1.15.0
SetRecent tells a finder which paths, relative to its root, the pane has open, most recent first. It is a no-op on a project search.
func (*Mode) Update ¶
Update feeds the surface its own async traffic. Both surfaces drop messages stamped with an epoch other than the one they were opened at.