523
}
524
525
>
async function fetchFileContents(
history.ts
526
>
folderPrefix: string | undefined,
527
>
filePath: string,
528
>
isFileWindows: boolean,
529
>
fileService: Pick<IFileService, 'readFile'>,
530
>
remoteAgentService: Pick<IRemoteAgentService, 'getConnection'>,
531
>
): Promise<{ resource: URI; content: string } | undefined> {
532
>
if (!folderPrefix) {
533
return undefined;
534
}
535
>
const connection = remoteAgentService.getConnection();
history.ts
536
>
const isRemote = !!connection?.remoteAuthority;
537
>
const resource = URI.from({
538
>
scheme: isRemote ? Schemas.vscodeRemote : Schemas.file,
539
>
authority: isRemote ? connection.remoteAuthority : undefined,
540
>
path: URI.file(join(folderPrefix, filePath)).path
541
>
});
542
>
let content: IFileContent;
543
>
try {
544
>
content = await fileService.readFile(resource);
545
>
} catch (e: unknown) {
546
// Handle file not found only
547
if (e instanceof FileOperationError && e.fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {