@@ -11,8 +11,8 @@ module.exports = {
1111 activate ( state ) {
1212 this . active = false
1313 this . fnrVisible = false
14- this . bindingsById = { }
15- this . subscriptionsById = { }
14+ this . bindingsById = new Map ( )
15+ this . subscriptionsById = new Map ( )
1616 this . subscriptions = new CompositeDisposable ( )
1717 require ( 'atom-package-deps' ) . install ( 'minimap-find-and-replace' )
1818 } ,
@@ -46,23 +46,23 @@ module.exports = {
4646 MinimapFindAndReplaceBinding = require ( './minimap-find-and-replace-binding' )
4747 }
4848
49- const {
50- id,
51- } = minimap
49+ const { id } = minimap
5250 const binding = new MinimapFindAndReplaceBinding ( minimap , fnr , this . fnrVisible )
53- this . bindingsById [ id ] = binding
54-
55- this . subscriptionsById [ id ] = minimap . onDidDestroy ( ( ) => {
56- if ( this . subscriptionsById [ id ] ) {
57- this . subscriptionsById [ id ] . dispose ( )
58- }
59- if ( this . bindingsById [ id ] ) {
60- this . bindingsById [ id ] . destroy ( )
61- }
62-
63- delete this . bindingsById [ id ]
64- delete this . subscriptionsById [ id ]
65- } )
51+ this . bindingsById . set ( id , binding )
52+
53+ this . subscriptionsById . set ( id ,
54+ minimap . onDidDestroy ( ( ) => {
55+ if ( this . subscriptionsById . has ( id ) ) {
56+ this . subscriptionsById . get ( id ) . dispose ( )
57+ }
58+ if ( this . bindingsById . has ( id ) ) {
59+ this . bindingsById . get ( id ) . destroy ( )
60+ }
61+
62+ this . bindingsById . delete ( id )
63+ this . subscriptionsById . delete ( id )
64+ } ) ,
65+ )
6666 } ) )
6767 } )
6868 } ,
@@ -87,25 +87,28 @@ module.exports = {
8787
8888 changeVisible ( visible ) {
8989 this . fnrVisible = visible
90- for ( const id in this . bindingsById ) {
91- this . bindingsById [ id ] . changeVisible ( visible )
90+ const bindings = this . bindingsById . values ( )
91+ for ( const binding of bindings ) {
92+ binding . changeVisible ( visible )
9293 }
9394 } ,
9495
9596 deactivatePlugin ( ) {
96- let id
9797 if ( ! this . active ) {
9898 return
9999 }
100100
101101 this . active = false
102102 this . subscriptions . dispose ( )
103103
104- for ( id in this . subscriptionsById ) {
105- const sub = this . subscriptionsById [ id ] ; sub . dispose ( )
104+ const subscriptions = this . subscriptionsById . values ( )
105+ for ( const subscription of subscriptions ) {
106+ subscription . dispose ( )
106107 }
107- for ( id in this . bindingsById ) {
108- const binding = this . bindingsById [ id ] ; binding . destroy ( )
108+
109+ const bindings = this . bindingsById . values ( )
110+ for ( const binding of bindings ) {
111+ binding . destroy ( )
109112 }
110113
111114 this . bindingsById = { }
0 commit comments