Skip to content

EditorSearch beta ​

Class of @v12-engine/editor

ts
export declare class EditorSearch

The editor's search: its sources, and what was used last (kept for the next time). The editor's own sources are there from the start; a game adds its own declared (EditorOptions.search) or in code (add)

Members ​

constructor ​

ts
constructor(sources: SearchSource[], changed?: () => void, 
    storage?: () => KeptStorage);

Constructs a new instance of the EditorSearch class

add ​

ts
add(source: SearchSource, options?: {
        before?: string;
    }): () => void;

Adds a source: before another by id, or last. One with the id of another takes its place. Gives back what takes it out

find ​

ts
find(found: readonly FoundEntry[], query: string, first?: (entry: FoundEntry) => boolean): FoundEntry[];

Searches what gather found (see searchEntries): what first says before the rest; a typo finds, where an entry's source allows (SearchSource.fuzzy)

gather ​

ts
gather(editor: EditorClient, each?: (found: FoundEntry[]) => void): Promise<FoundEntry[]>;

Every entry of every source, now: those of a source that fails are left out

prefixes ​

ts
prefixes(): Record<string, string>;

The sources searched alone by a first character, by it

recent ​

ts
recent(): readonly string[];

What was used last, latest first, as source:id

remove ​

ts
remove(id: string): void;

Takes out the source with that id; nothing happens when there is none

run ​

ts
run(entry: FoundEntry, editor: EditorClient): Promise<void>;

Does what an entry does, and keeps it first among what was used last

sources ​

ts
sources(): readonly SearchSource[];

Where it looks, in order