Skip to content

fix: suggest collections with dots in them #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/mongodb-ts-autocomplete/src/autocompleter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('MongoDBAutocompleter', function () {
databasesForConnection: () =>
Promise.resolve(['db1', 'db2', databaseName]),
collectionsForDatabase: () =>
Promise.resolve(['foo', 'bar', 'baz', collectionName]),
Promise.resolve(['foo', 'bar', 'baz', collectionName, 'one.two']),
schemaInformationForCollection: async (
connectionId: string,
databaseName: string,
Expand Down Expand Up @@ -217,6 +217,19 @@ describe('MongoDBAutocompleter', function () {
}
});

it('completes a collection name with a dot in it', async function () {
for (let i = 0; i < 2; i++) {
const completions = await autocompleter.autocomplete('db.on');
expect(completions).to.deep.equal([
{
kind: 'property',
name: 'one.two',
result: 'db.one.two',
},
]);
}
});

it('completes a collection method', async function () {
for (let i = 0; i < 2; i++) {
const completions = await autocompleter.autocomplete('db.foo.fi');
Expand Down
2 changes: 2 additions & 0 deletions packages/ts-autocomplete/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ export default class Autocompleter {
code.length,
{
allowIncompleteCompletions: true,
// https://github.com/microsoft/TypeScript/blob/833a8d492c728d606454865e8c0fee84842f9f10/tests/baselines/reference/api/typescript.d.ts#L8311-L8315
includeCompletionsWithInsertText: true,
},
);

Expand Down