Codelet logoCodelet

Search

The sidebar Search view, searching file contents and paths across the workspace.

search adds a Search icon to the activity bar with a view that searches every file in the workspace. Without this extension, the workbench has no Search icon at all.

import { search } from "codelet/extensions/search";
import { Workbench, FileSystem } from "codelet/workbench";

const workbench = new Workbench({
  parent: document.getElementById("app")!,
  fs: new FileSystem({ "/README.md": "# Hello" }),
  extensions: [search],
});

search takes no options.

#Try it

Click the Search icon in the activity bar and type greet.

#What it searches

Typing in the filter box runs a case-insensitive substring search over every file's text, and over file paths. The view re-runs the search whenever a file changes or is deleted, and starts empty: nothing is listed until you type.

#Reading the results

Results are listed as a tree, one row per file with a match under it for each line. Clicking a match opens its file with the line selected. A file listed only because its path matched, and not its contents, opens directly instead of expanding.

The view's message line above the results reports how many results were found, in how many files. A search stops after the first 500 matches and says so, rather than silently truncating.

#The row menu

A right-click on a result opens three items:

ItemOnWhat it does
Open FileA file rowOpens the file. A file with matches expands on a click, so this is the way in.
CopyEitherThe file's path, or the matched line.
DismissEitherTakes that row off the list.

Dismissing is about the answer on screen, not about the file: the next search — a keystroke, an edit, a file deleted, or a new list of references — brings every row back.

The browser only gives a page a clipboard in a secure context, so a workbench served over plain http shows no Copy item at all rather than one that silently does nothing.

Read more in Extensions.