Skip to content

Commit d670744

Browse files
committed
Improve peek to include all matches
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
1 parent d786007 commit d670744

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/language/providers/peekProvider.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,21 @@ export const peekProvider = languages.registerDefinitionProvider({ language: `sq
4040

4141
const possibleObjects = await Schemas.resolveObjects([{name, schema}], [`*LIB`]);
4242

43-
if (possibleObjects.length === 1) {
44-
const obj = possibleObjects[0];
45-
const content = await Schemas.generateSQL(obj.schema, obj.name, obj.sqlType, true);
43+
let totalBlocks: string[] = [];
4644

47-
const document = await workspace.openTextDocument({ content, language: `sql` });
45+
if (possibleObjects.length > 0) {
46+
if (possibleObjects.length > 1) {
47+
totalBlocks.push(
48+
`-- Multiple objects found with the same name.`
49+
);
50+
}
51+
52+
for (const posObj of possibleObjects) {
53+
const newContent = await Schemas.generateSQL(posObj.schema, posObj.name, posObj.sqlType, true);
54+
totalBlocks.push(newContent);
55+
}
56+
57+
const document = await workspace.openTextDocument({ content: totalBlocks.join(`\n\n`), language: `sql` });
4858

4959
return {
5060
uri: document.uri,

0 commit comments

Comments
 (0)