Skip to content

Commit 971318f

Browse files
committed
bump mongodb-ts-autocomplete, return and check undefined
1 parent ebb3c68 commit 971318f

File tree

6 files changed

+36
-32
lines changed

6 files changed

+36
-32
lines changed

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/autocomplete/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"dependencies": {
4646
"@mongodb-js/mongodb-constants": "^0.10.1",
4747
"@mongosh/shell-api": "^3.11.0",
48-
"@mongodb-js/mongodb-ts-autocomplete": "^0.2.4",
48+
"@mongodb-js/mongodb-ts-autocomplete": "^0.2.5",
4949
"semver": "^7.5.4"
5050
}
5151
}

packages/browser-runtime-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
4242
"@mongodb-js/prettier-config-devtools": "^1.0.1",
4343
"@mongodb-js/tsconfig-mongosh": "^1.0.0",
44-
"@mongodb-js/mongodb-ts-autocomplete": "^0.2.4",
44+
"@mongodb-js/mongodb-ts-autocomplete": "^0.2.5",
4545
"@mongosh/types": "3.6.2",
4646
"bson": "^6.10.3",
4747
"depcheck": "^1.4.7",

packages/shell-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"devDependencies": {
6565
"@microsoft/api-extractor": "^7.39.3",
6666
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
67-
"@mongodb-js/mongodb-ts-autocomplete": "^0.2.4",
67+
"@mongodb-js/mongodb-ts-autocomplete": "^0.2.5",
6868
"@mongodb-js/prettier-config-devtools": "^1.0.1",
6969
"@mongodb-js/tsconfig-mongosh": "^1.0.0",
7070
"@mongosh/types": "3.6.2",

packages/shell-api/src/shell-api.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,11 @@ async function newUseCompleter(
145145
): Promise<string[] | undefined> {
146146
if (args.length > 2) return undefined;
147147

148-
let connectionId: string;
149-
150-
try {
151-
({ connectionId } = context.currentDatabaseAndConnection());
152-
} catch (err: any) {
153-
if (err.name === 'MongoshInvalidInputError') {
154-
return [];
155-
}
156-
throw err;
148+
const dbAndConnection = context.currentDatabaseAndConnection();
149+
if (!dbAndConnection) {
150+
return [];
157151
}
152+
const { connectionId } = dbAndConnection;
158153

159154
const dbNames = await context.databasesForConnection(connectionId);
160155

packages/shell-api/src/shell-instance-state.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,23 @@ export class ShellInstanceState {
417417

418418
public getAutocompletionContext(): AutocompletionContext {
419419
return {
420-
currentDatabaseAndConnection: (): {
421-
connectionId: string;
422-
databaseName: string;
423-
} => {
424-
return {
425-
connectionId: this.currentDb.getMongo()._getConnectionId(),
426-
databaseName: this.currentDb.getName(),
427-
};
420+
currentDatabaseAndConnection: ():
421+
| {
422+
connectionId: string;
423+
databaseName: string;
424+
}
425+
| undefined => {
426+
try {
427+
return {
428+
connectionId: this.currentDb.getMongo()._getConnectionId(),
429+
databaseName: this.currentDb.getName(),
430+
};
431+
} catch (err: any) {
432+
if (err.name === 'MongoshInvalidInputError') {
433+
return undefined;
434+
}
435+
throw err;
436+
}
428437
},
429438
databasesForConnection: async (
430439
connectionId: string

0 commit comments

Comments
 (0)