(tokens: string[])
| 222 | } |
| 223 | |
| 224 | function parseRead(tokens: string[]): ExploreEntry[] | null { |
| 225 | const paths = findPathTokens(tokens).filter(Boolean); |
| 226 | if (paths.length === 0) { |
| 227 | return null; |
| 228 | } |
| 229 | const entries = paths.map((path) => { |
| 230 | const name = path.split(/[\\/]/g).filter(Boolean).pop() ?? path; |
| 231 | return name && name !== path |
| 232 | ? ({ kind: "read", label: name, detail: path } satisfies ExploreEntry) |
| 233 | : ({ kind: "read", label: path } satisfies ExploreEntry); |
| 234 | }); |
| 235 | const seen = new Set<string>(); |
| 236 | const deduped: ExploreEntry[] = []; |
| 237 | for (const entry of entries) { |
| 238 | const key = entry.detail ? `${entry.label}|${entry.detail}` : entry.label; |
| 239 | if (seen.has(key)) { |
| 240 | continue; |
| 241 | } |
| 242 | seen.add(key); |
| 243 | deduped.push(entry); |
| 244 | } |
| 245 | return deduped; |
| 246 | } |
| 247 | |
| 248 | function parseList(tokens: string[]): ExploreEntry { |
| 249 | const paths = findPathTokens(tokens); |
no test coverage detected