File tree Expand file tree Collapse file tree 6 files changed +36
-32
lines changed
Expand file tree Collapse file tree 6 files changed +36
-32
lines changed Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments