( rif: RangeInFileWithContents, )
| 4 | import { findUriInDirs, getUriPathBasename } from "../util/uri"; |
| 5 | |
| 6 | export function rifWithContentsToContextItem( |
| 7 | rif: RangeInFileWithContents, |
| 8 | ): ContextItemWithId { |
| 9 | const basename = getUriPathBasename(rif.filepath); |
| 10 | const { relativePathOrBasename, foundInDir, uri } = findUriInDirs( |
| 11 | rif.filepath, |
| 12 | window.workspacePaths ?? [], |
| 13 | ); |
| 14 | const rangeStr = `(${rif.range.start.line + 1}-${rif.range.end.line + 1})`; |
| 15 | |
| 16 | return { |
| 17 | content: rif.contents, |
| 18 | name: `${basename} ${rangeStr}`, |
| 19 | description: `${relativePathOrBasename} ${rangeStr}`, |
| 20 | id: { |
| 21 | providerTitle: "code", |
| 22 | itemId: uuidv4(), |
| 23 | }, |
| 24 | uri: { |
| 25 | type: "file", |
| 26 | value: rif.filepath, |
| 27 | }, |
| 28 | }; |
| 29 | } |
| 30 | |
| 31 | export function ctxItemToRifWithContents( |
| 32 | item: ContextItemWithId, |
no test coverage detected