From 14bb3ad90d3fc013c632ade12eaf40f7b028e3a8 Mon Sep 17 00:00:00 2001 From: Dario Carnevale Schianca Date: Wed, 11 Feb 2026 16:18:16 +0100 Subject: [PATCH] Update connection.defaultUserLibraries by fetching the current library list from the server --- src/api/CompileTools.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/api/CompileTools.ts b/src/api/CompileTools.ts index a9ca167bd..9d0be943b 100644 --- a/src/api/CompileTools.ts +++ b/src/api/CompileTools.ts @@ -29,6 +29,7 @@ export namespace CompileTools { * Execute a command */ export async function runCommand(connection: IBMi, options: RemoteCommand, events: RunCommandEvents = {}): Promise { + await updateDefaultUserLibraries(connection); const config = connection.getConfig(); if (config && connection) { const cwd = options.cwd; @@ -194,4 +195,34 @@ export namespace CompileTools { `liblist -a ${IBMi.escapeForShell(Tools.sanitizeObjNamesForPase(buildLibraryList(config)).join(` `))}` ]; } + + /** + * Update connection.defaultUserLibraries by fetching the current library list from the server + * @param connection IBMi connection + */ + + async function updateDefaultUserLibraries(connection: IBMi): Promise { + const liblResult = await connection.sendQsh({ + command: `liblist` + }); + + if (liblResult.code === 0 && liblResult.stdout) { + const userLibraries: string[] = []; + const libraryList = liblResult.stdout.split(`\n`); + + for (const line of libraryList) { + const lib = line.substring(0, 10).trim(); + const type = line.substring(12).trim(); + + if (lib && type === `USR`) { + userLibraries.push(lib); + } + } + + // Update connection.defaultUserLibraries with the libraries from the server + connection.defaultUserLibraries = userLibraries; + + } + } + } \ No newline at end of file