MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / buildFdPathQuery

Function buildFdPathQuery

packages/pi-tui/src/autocomplete.ts:17–43  ·  view source on GitHub ↗
(query: string)

Source from the content-addressed store, hash-verified

15}
16
17function buildFdPathQuery(query: string): string {
18 const normalized = toDisplayPath(query);
19 if (!normalized.includes("/")) {
20 return normalized;
21 }
22
23 const hasTrailingSeparator = normalized.endsWith("/");
24 const trimmed = normalized.replace(/^\/+|\/+$/g, "");
25 if (!trimmed) {
26 return normalized;
27 }
28
29 const separatorPattern = "[\\\\/]";
30 const segments = trimmed
31 .split("/")
32 .filter(Boolean)
33 .map((segment) => escapeRegex(segment));
34 if (segments.length === 0) {
35 return normalized;
36 }
37
38 let pattern = segments.join(separatorPattern);
39 if (hasTrailingSeparator) {
40 pattern += separatorPattern;
41 }
42 return pattern;
43}
44
45function findLastDelimiter(text: string): number {
46 for (let i = text.length - 1; i >= 0; i -= 1) {

Callers 1

walkDirectoryWithFdFunction · 0.85

Calls 2

toDisplayPathFunction · 0.85
escapeRegexFunction · 0.85

Tested by

no test coverage detected