Skip to content

Commit 64e86ac

Browse files
authored
fix: suggest collections with dots in them (#561)
suggest collections with dots in them
1 parent 89e93bb commit 64e86ac

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/mongodb-ts-autocomplete/src/autocompleter.spec.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('MongoDBAutocompleter', function () {
8686
databasesForConnection: () =>
8787
Promise.resolve(['db1', 'db2', databaseName]),
8888
collectionsForDatabase: () =>
89-
Promise.resolve(['foo', 'bar', 'baz', collectionName]),
89+
Promise.resolve(['foo', 'bar', 'baz', collectionName, 'one.two']),
9090
schemaInformationForCollection: async (
9191
connectionId: string,
9292
databaseName: string,
@@ -213,6 +213,19 @@ service host, so typescript wouldn't load all the dependencies.
213213
}
214214
});
215215

216+
it('completes a collection name with a dot in it', async function () {
217+
for (let i = 0; i < 2; i++) {
218+
const completions = await autocompleter.autocomplete('db.on');
219+
expect(completions).to.deep.equal([
220+
{
221+
kind: 'property',
222+
name: 'one.two',
223+
result: 'db.one.two',
224+
},
225+
]);
226+
}
227+
});
228+
216229
it('completes a collection method', async function () {
217230
for (let i = 0; i < 2; i++) {
218231
const completions = await autocompleter.autocomplete('db.foo.fi');

packages/ts-autocomplete/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ export default class Autocompleter {
256256
code.length,
257257
{
258258
allowIncompleteCompletions: true,
259+
// https://github.com/microsoft/TypeScript/blob/833a8d492c728d606454865e8c0fee84842f9f10/tests/baselines/reference/api/typescript.d.ts#L8311-L8315
260+
includeCompletionsWithInsertText: true,
259261
},
260262
);
261263

0 commit comments

Comments
 (0)