@@ -9,8 +9,8 @@ class MinimapFindAndReplaceBinding {
99 this . fnrVisible = fnrVisible
1010 this . editor = this . minimap . getTextEditor ( )
1111 this . subscriptions = new CompositeDisposable ( )
12- this . decorationsByMarkerId = { }
13- this . subscriptionsByMarkerId = { }
12+ this . decorationsByMarkerId = new Map ( )
13+ this . subscriptionsByMarkerId = new Map ( )
1414
1515 this . layer = this . fnrAPI . resultsMarkerLayerForTextEditor ( this . editor )
1616
@@ -23,20 +23,22 @@ class MinimapFindAndReplaceBinding {
2323 this . discoverMarkers ( )
2424 }
2525
26- destroy ( ) {
27- let id
28- for ( id in this . subscriptionsByMarkerId ) {
29- const sub = this . subscriptionsByMarkerId [ id ] ; sub . dispose ( )
26+ disposeMarkerSubsctiotions ( ) {
27+ const markerSubscriptions = this . subscriptionsByMarkerId . values ( )
28+ for ( const markerSubscription of markerSubscriptions ) {
29+ markerSubscription . dispose ( )
3030 }
31- for ( id in this . decorationsByMarkerId ) {
32- const decoration = this . decorationsByMarkerId [ id ] ; decoration . destroy ( )
31+ const decorationSubscriotions = this . decorationsByMarkerId . values ( )
32+ for ( const decorationSubscriotion of decorationSubscriotions ) {
33+ decorationSubscriotion . destroy ( )
3334 }
35+ }
3436
37+ destroy ( ) {
3538 this . subscriptions . dispose ( )
39+ this . clear ( )
3640 this . minimap = null
3741 this . editor = null
38- this . decorationsByMarkerId = { }
39- this . subscriptionsByMarkerId = { }
4042 }
4143
4244 changeVisible ( visible ) {
@@ -49,23 +51,15 @@ class MinimapFindAndReplaceBinding {
4951 }
5052
5153 clear ( ) {
52- let id
53- for ( id in this . subscriptionsByMarkerId ) {
54- const sub = this . subscriptionsByMarkerId [ id ]
55- sub . dispose ( )
56- delete this . subscriptionsByMarkerId [ id ]
57- }
58-
59- for ( id in this . decorationsByMarkerId ) {
60- const decoration = this . decorationsByMarkerId [ id ]
61- decoration . destroy ( )
62- delete this . decorationsByMarkerId [ id ]
63- }
54+ this . disposeMarkerSubsctiotions ( )
55+ this . decorationsByMarkerId . clear ( )
56+ this . subscriptionsByMarkerId . clear ( )
6457 }
6558
6659 discoverMarkers ( ) {
6760 setImmediate ( ( ) => {
68- for ( const marker of this . layer . getMarkers ( ) ) {
61+ const markers = this . layer . getMarkers ( )
62+ for ( const marker of markers ) {
6963 this . createDecoration ( marker )
7064 }
7165 } )
@@ -75,7 +69,7 @@ class MinimapFindAndReplaceBinding {
7569 if ( ! this . findViewIsVisible ( ) ) {
7670 return
7771 }
78- if ( this . decorationsByMarkerId [ marker . id ] ) {
72+ if ( this . decorationsByMarkerId . has ( marker . id ) ) {
7973 return
8074 }
8175
@@ -89,15 +83,14 @@ class MinimapFindAndReplaceBinding {
8983 return
9084 }
9185
92- const {
93- id,
94- } = marker
95- this . decorationsByMarkerId [ id ] = decoration
96- this . subscriptionsByMarkerId [ id ] = decoration . onDidDestroy ( ( ) => {
97- this . subscriptionsByMarkerId [ id ] . dispose ( )
98- delete this . decorationsByMarkerId [ id ]
99- delete this . subscriptionsByMarkerId [ id ]
100- } )
86+ const { id } = marker
87+ this . decorationsByMarkerId . set ( id , decoration )
88+ this . subscriptionsByMarkerId . set ( id ,
89+ decoration . onDidDestroy ( ( ) => {
90+ this . subscriptionsByMarkerId . get ( id ) . dispose ( )
91+ this . subscriptionsByMarkerId . delete ( id )
92+ } ) ,
93+ )
10194 }
10295
10396 findViewIsVisible ( ) {
0 commit comments