diff --git a/packages/zowe-explorer/src/trees/job/JobFSProvider.ts b/packages/zowe-explorer/src/trees/job/JobFSProvider.ts index 2aee3ed16..d8dfa7833 100644 --- a/packages/zowe-explorer/src/trees/job/JobFSProvider.ts +++ b/packages/zowe-explorer/src/trees/job/JobFSProvider.ts @@ -207,11 +207,16 @@ export class JobFSProvider extends BaseProvider implements vscode.FileSystemProv const bufBuilder = new BufferBuilder(); const jesApi = ZoweExplorerApiRegister.getJesApi(spoolEntry.metadata.profile); + + const queryParams = new URLSearchParams(uri.query); + const startRecord = Number(queryParams.get("startRecord")); + try { if (jesApi.downloadSingleSpool) { const spoolDownloadObject: IDownloadSpoolContentParms = { jobFile: spoolEntry.spool, stream: bufBuilder, + startRecord, }; // Handle encoding and binary options @@ -232,7 +237,17 @@ export class JobFSProvider extends BaseProvider implements vscode.FileSystemProv } this._fireSoon({ type: vscode.FileChangeType.Changed, uri }); - spoolEntry.data = bufBuilder.read() ?? new Uint8Array(); + if (startRecord > 0) { + const newContents: Uint8Array | null = bufBuilder.read(); + if (newContents != null) { + const combined = new Uint8Array(spoolEntry.data.length + newContents.length); + combined.set(spoolEntry.data, 0); + combined.set(newContents, spoolEntry.data.length); + spoolEntry.data = combined; + } + } else { + spoolEntry.data = bufBuilder.read() ?? new Uint8Array(); + } spoolEntry.mtime = Date.now(); spoolEntry.size = spoolEntry.data.byteLength; if (editor) { diff --git a/packages/zowe-explorer/src/trees/job/JobInit.ts b/packages/zowe-explorer/src/trees/job/JobInit.ts index 93a13ad49..31cbdfc25 100644 --- a/packages/zowe-explorer/src/trees/job/JobInit.ts +++ b/packages/zowe-explorer/src/trees/job/JobInit.ts @@ -10,7 +10,7 @@ */ import * as vscode from "vscode"; -import { IZoweJobTreeNode, IZoweTreeNode, ZoweScheme, imperative, Gui } from "@zowe/zowe-explorer-api"; +import { IZoweJobTreeNode, IZoweTreeNode, ZoweScheme, imperative, Gui, FsJobsUtils } from "@zowe/zowe-explorer-api"; import { JobTree } from "./JobTree"; import { JobActions } from "./JobActions"; import { ZoweJobNode } from "./ZoweJobNode"; @@ -162,6 +162,29 @@ export class JobInit { JobFSProvider.instance.cacheOpenedUri(doc.uri); }) ); + context.subscriptions.push( + vscode.window.onDidChangeTextEditorVisibleRanges(async (e) => { + const documentUri = e.textEditor.document.uri; + if (documentUri.scheme !== ZoweScheme.Jobs) { + return; + } + const spool = JobFSProvider.instance.lookup(documentUri, true); + if (spool == null || !FsJobsUtils.isSpoolEntry(spool)) { + return; + } + + for (const range of e.visibleRanges) { + // if range contains line count of document the line count is + // less than the record count of the spool, attempt to fetch more records + if ( + range.contains(new vscode.Position(e.textEditor.document.lineCount, 1)) && + e.textEditor.document.lineCount < spool.spool?.["record-count"] + ) { + await JobFSProvider.instance.fetchSpoolAtUri(documentUri.with({ query: `?startRecord=${e.textEditor.document.lineCount}` })); + } + } + }) + ); SharedInit.initSubscribers(context, jobsProvider); return jobsProvider; }