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) 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 = 30 * time.Second
CacheTTL is how long a root's file list is trusted without a rescan.
The Files plugin has a filesystem watcher and marks its cache dirty the moment the tree moves; the pane surfaces have no such signal, so there is nothing here to invalidate the list precisely. A short lifetime is the honest substitute: the second ctrl+p in a working session costs nothing, and a finder opened minutes later still sees files created since.
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, rescanning it if the last walk has aged out.
func (*Caches) NoteScan ¶
NoteScan records that a scan of root has just been issued. Only a scan that actually started moves the clock, so a cache that answered from memory keeps the age of the walk it is still showing.
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 finder owns nothing (its file list belongs to the caller's per-root cache); the project search owns a running ripgrep process, which would otherwise keep going to its timeout.
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) 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.