File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 1+ import { isAbsolute , join } from 'path' ;
12import { Tokenizer } from './build-file-index' ;
23import { ContentReader } from './ioutil' ;
34import SnippetIndex from './snippet-index' ;
@@ -16,14 +17,16 @@ type Context = {
1617} ;
1718
1819async function indexFile ( context : Context , file : File ) {
19- const fileContent = await context . contentReader ( file . filePath ) ;
20+ const filePath = isAbsolute ( file . filePath ) ? file . filePath : join ( file . directory , file . filePath ) ;
21+
22+ const fileContent = await context . contentReader ( filePath ) ;
2023 if ( ! fileContent ) return ;
2124
2225 const extension = file . filePath . split ( '.' ) . pop ( ) || '' ;
2326 const chunks = await context . splitter ( fileContent , extension ) ;
2427
2528 chunks . forEach ( ( chunk , index ) => {
26- const snippetId = `${ file . filePath } :${ index } ` ;
29+ const snippetId = `${ filePath } :${ index } ` ;
2730 const { content, startLine, endLine } = chunk ;
2831 context . snippetIndex . indexSnippet (
2932 snippetId ,
You can’t perform that action at this time.
0 commit comments