panesearch

package
v1.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

func (c *Caches) For(root string) *filefind.Cache

For returns the file list for root. The cache rescans itself on its next Ensure once its last walk has aged out.

func (*Caches) Len

func (c *Caches) Len() int

Len is how many roots have a cached file list.

func (*Caches) Scanned

func (c *Caches) Scanned(root string) time.Time

Scanned is when root's list was last walked, or the zero time if it has never been walked.

func (*Caches) SetScanned

func (c *Caches) SetScanned(root string, at time.Time)

SetScanned backdates (or forwards) root's last walk and forgets its directory stamps, so the next finder open walks the tree rather than probing it. It exists so a caller can age a list out deliberately.

type Kind

type Kind int

Kind names which surface a pane is showing.

const (
	KindFinder Kind = iota + 1
	KindProject
)

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

func NewFinder(caches *Caches, root string, epoch uint64) (*Mode, tea.Cmd)

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

func NewProject(root string, epoch uint64) *Mode

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

func (m *Mode) Finder() *filefind.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) HandleKey

func (m *Mode) HandleKey(msg tea.KeyPressMsg) (Outcome, tea.Cmd)

func (*Mode) HandleMouse

func (m *Mode) HandleMouse(msg tea.MouseMsg, handler *mouse.Handler) (Outcome, tea.Cmd)

func (*Mode) HeaderLabel

func (m *Mode) HeaderLabel() string

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) Kind

func (m *Mode) Kind() Kind

func (*Mode) Name

func (m *Mode) Name() string

func (*Mode) Query

func (m *Mode) Query() string

Query is what the user has typed, for the pane header.

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

func (m *Mode) SetRecent(paths []string)

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) SetSize

func (m *Mode) SetSize(width, height int)

func (*Mode) Update

func (m *Mode) Update(msg tea.Msg) tea.Cmd

Update feeds the surface its own async traffic. Both surfaces drop messages stamped with an epoch other than the one they were opened at.

func (*Mode) View

func (m *Mode) View(width, height int, fill bool, handler *mouse.Handler) string

View draws the surface at the given size. fill is panemodal's answer to whether the box has room to show the pane around the modal; passing it through is what makes the tight case a modal that owns the pane rather than a small box floating on an empty field.

type Outcome

type Outcome struct {
	Cancelled bool
	Open      bool
	Path      string
	Line      int
	NewTab    bool
}

Outcome is the two surfaces' Result narrowed to what a pane host can act on: drop the mode, or load a file into the pane.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL