(
id: number,
workspaceDirs: string[],
)
| 349 | } |
| 350 | |
| 351 | static async getForId( |
| 352 | id: number, |
| 353 | workspaceDirs: string[], |
| 354 | ): Promise<ContextItem> { |
| 355 | const db = await SqliteDb.get(); |
| 356 | const row = await db.get("SELECT * FROM code_snippets WHERE id = ?", [id]); |
| 357 | |
| 358 | const last2Parts = getLastNUriRelativePathParts(workspaceDirs, row.path, 2); |
| 359 | const { relativePathOrBasename } = findUriInDirs(row.path, workspaceDirs); |
| 360 | return { |
| 361 | name: row.title, |
| 362 | description: last2Parts, |
| 363 | content: `\`\`\`${relativePathOrBasename}\n${row.content}\n\`\`\``, |
| 364 | uri: { |
| 365 | type: "file", |
| 366 | value: row.path, |
| 367 | }, |
| 368 | }; |
| 369 | } |
| 370 | |
| 371 | static async getAll(tag: IndexTag): Promise<ContextSubmenuItem[]> { |
| 372 | const db = await SqliteDb.get(); |
no test coverage detected