Skip to content

Commit 38895ed

Browse files
authored
Merge pull request #297 from codefori/fix/continue-context
ignore context item it its empty
2 parents 28f9fb4 + 88eba79 commit 38895ed

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/aiProviders/continue/continueContextProvider.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,20 @@ export class db2ContextProvider implements IContextProvider {
146146
);
147147
for (const table of Object.keys(tableRefs)) {
148148
const columnData: TableColumn[] = tableRefs[table];
149-
const tableSchema =
150-
columnData.length > 0 ? columnData[0].TABLE_SCHEMA : null;
151-
152-
// create context item
153-
let prompt = `Db2 for i Table meta data for schema ${tableSchema} table ${table}\n`;
154-
prompt += `Column Info: ${JSON.stringify(columnData)}\n\n`;
155-
156-
contextItems.push({
157-
name: `${job.name}-${tableSchema}-${table}`,
158-
description: `Schema and table information for ${table}`,
159-
content: prompt,
160-
});
149+
if (columnData && columnData.length > 0) {
150+
const tableSchema =
151+
columnData.length > 0 ? columnData[0].TABLE_SCHEMA : null;
152+
153+
// create context item
154+
let prompt = `Db2 for i Table meta data for schema ${tableSchema} table ${table}\n`;
155+
prompt += `Column Info: ${JSON.stringify(columnData)}\n\n`;
156+
157+
contextItems.push({
158+
name: `${job.name}-${tableSchema}-${table}`,
159+
description: `Schema and table information for ${table}`,
160+
content: prompt,
161+
});
162+
}
161163
}
162164

163165
return contextItems;
@@ -195,6 +197,5 @@ export async function registerContinueProvider() {
195197
const continueAPI = continueEx?.exports;
196198
continueAPI?.registerCustomContextProvider(provider);
197199
vscode.commands.executeCommand('setContext', 'vscode-db2i:continueExtensionActive', true);
198-
vscode.window.showInformationMessage(`@Db2i context provider enabled in Continue!`);
199200
}
200201
}

0 commit comments

Comments
 (0)