The lookup as it was before the index: a LIKE scan, ties left to the plan.
(db: SqliteDatabase, substring: string, kinds: string[], excludePrefix: boolean, limit: number)
| 50 | |
| 51 | /** The lookup as it was before the index: a LIKE scan, ties left to the plan. */ |
| 52 | function likeScan(db: SqliteDatabase, substring: string, kinds: string[], excludePrefix: boolean, limit: number): string[] { |
| 53 | let sql = 'SELECT nodes.*, 1.0 as score FROM nodes WHERE name LIKE ?'; |
| 54 | const params: (string | number)[] = [`%${substring}%`]; |
| 55 | if (excludePrefix) { sql += ' AND name NOT LIKE ?'; params.push(`${substring}%`); } |
| 56 | sql += ` AND kind IN (${kinds.map(() => '?').join(',')}) ORDER BY length(name) ASC LIMIT ?`; |
| 57 | return (db.prepare(sql).all(...params, ...kinds, limit) as Array<{ id: string }>).map((row) => row.id); |
| 58 | } |
| 59 | |
| 60 | /** Many names of equal length across kinds and files, so ties decide the order. */ |
| 61 | function writeTieProject(dir: string): void { |
no test coverage detected