@@ -5,39 +5,43 @@ import type { DatatipService } from "atom-ide-base"
5
5
export { default as config } from "./config.json"
6
6
7
7
/** [subscriptions description] */
8
- let subscriptions : CompositeDisposable
8
+ const subscriptions : CompositeDisposable = new CompositeDisposable ( )
9
9
/** [datatipManager description] */
10
- let datatipManager : DataTipManager
10
+ let datatipManager : DataTipManager | undefined
11
11
12
12
/** Called by Atom when activating an extension */
13
13
export function activate ( ) {
14
14
// Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
15
- subscriptions = new CompositeDisposable ( )
16
- if ( ! datatipManager ) {
15
+ if ( datatipManager === undefined ) {
17
16
datatipManager = new DataTipManager ( )
18
17
}
19
18
subscriptions . add ( datatipManager )
20
19
21
- install_deps ( ) . then ( ( ) => {
22
- datatipManager . initialize ( )
23
- } )
20
+ install_deps ( )
21
+ . then ( ( ) => {
22
+ datatipManager ! . initialize ( )
23
+ } )
24
+ . catch ( ( e ) => {
25
+ console . error ( e )
26
+ } )
24
27
}
25
28
26
29
async function install_deps ( ) {
27
30
// install package-deps if not loaded
28
31
if ( ! atom . packages . isPackageLoaded ( "busy-signal" ) ) {
29
32
// Dynamic import https://mariusschulz.com/blog/dynamic-import-expressions-in-typescript
30
- await import ( "atom-package-deps" ) . then ( ( atom_package_deps ) => {
31
- atom_package_deps . install ( "atom-ide-datatip" , true )
32
- } )
33
+ const atom_package_deps = await import ( "atom-package-deps" )
34
+ try {
35
+ await atom_package_deps . install ( "atom-ide-datatip" , true )
36
+ } catch ( err ) {
37
+ atom . notifications . addError ( err )
38
+ }
33
39
}
34
40
}
35
41
36
42
/** Called by Atom when deactivating an extension */
37
43
export function deactivate ( ) {
38
- if ( subscriptions ) {
39
- subscriptions . dispose ( )
40
- }
44
+ subscriptions . dispose ( )
41
45
}
42
46
43
47
/**
0 commit comments