Skip to content
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

fix(autocomplete): do not act as if input is completion MONGOSH-646 #735

Merged
merged 1 commit into from
Mar 22, 2021
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
4 changes: 2 additions & 2 deletions packages/autocomplete/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ describe('completer.completer', () => {

it('does not provide anything if there is a function call instead of a collection name', async() => {
const i = 'db.getMongo().find';
expect(await completer(standalone440, i)).to.deep.equal([[i], i]);
expect(await completer(standalone440, i)).to.deep.equal([[], i]);
});

it('provides results if the function call is getCollection', async() => {
Expand Down Expand Up @@ -479,7 +479,7 @@ describe('completer.completer', () => {

it('does not match if it is not .find or .aggregate', async() => {
const i = 'db.shipwrecks.moo({feature_type: "Wrecks - Visible"}).';
expect(await completer(standalone440, i)).to.deep.equal([[i], i]);
expect(await completer(standalone440, i)).to.deep.equal([[], i]);
});
});
});
6 changes: 3 additions & 3 deletions packages/autocomplete/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async function completer(params: AutocompleteParameters, line: string): Promise<
// alphanumeric character. This could be a function call, for example.
// In any case, we can't currently provide reasonable autocompletion
// suggestions for this.
return [[line], line];
return [[], line];
}

if (splitLine.length > 3) {
Expand All @@ -99,7 +99,7 @@ async function completer(params: AutocompleteParameters, line: string): Promise<
return [hits.length ? hits : [], line];
}
// This is something else, and we currently don't know what this is.
return [[line], line];
return [[], line];
}

// complete aggregation and collection queries/stages
Expand Down Expand Up @@ -134,7 +134,7 @@ async function completer(params: AutocompleteParameters, line: string): Promise<
return [hits.length ? hits : [], line];
}

return [[line], line];
return [[], line];
}

function isAcceptable(
Expand Down
11 changes: 10 additions & 1 deletion packages/cli-repl/src/cli-repl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,10 +809,19 @@ describe('CliRepl', () => {
await waitEval(cliRepl.bus);
});

it('completes JS value properties properly', async() => {
it('completes JS value properties properly (incomplete, double tab)', async() => {
input.write('JSON.\u0009\u0009');
await waitCompletion(cliRepl.bus);
expect(output).to.include('JSON.parse');
expect(output).to.include('JSON.stringify');
expect(output).not.to.include('rawValue');
});

it('completes JS value properties properly (complete, single tab)', async() => {
input.write('JSON.pa\u0009');
await waitCompletion(cliRepl.bus);
expect(output).to.include('JSON.parse');
expect(output).not.to.include('JSON.stringify');
expect(output).not.to.include('rawValue');
});
});
Expand Down