@@ -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,22 +23,22 @@ class MinimapFindAndReplaceBinding {
2323 this . discoverMarkers ( )
2424 }
2525
26- destroy ( ) {
27- const subscriptionsByMarkerIdKeys = Object . keys ( this . subscriptionsByMarkerId )
28- for ( let i = 0 , len = subscriptionsByMarkerIdKeys . length ; i < len ; i ++ ) {
29- this . subscriptionsByMarkerId [ subscriptionsByMarkerIdKeys [ i ] ] . dispose ( )
26+ disposeMarkerSubsctiotions ( ) {
27+ const markerSubscriptions = this . subscriptionsByMarkerId . values ( )
28+ for ( const markerSubscription of markerSubscriptions ) {
29+ markerSubscription . dispose ( )
3030 }
31-
32- const decorationsByMarkerIdKeys = Object . keys ( this . decorationsByMarkerId )
33- for ( let i = 0 , len = decorationsByMarkerIdKeys . length ; i < len ; i ++ ) {
34- this . decorationsByMarkerId [ decorationsByMarkerIdKeys [ i ] ] . destroy ( )
31+ const decorationSubscriotions = this . decorationsByMarkerId . values ( )
32+ for ( const decorationSubscriotion of decorationSubscriotions ) {
33+ decorationSubscriotion . destroy ( )
3534 }
35+ }
3636
37+ destroy ( ) {
3738 this . subscriptions . dispose ( )
39+ this . clear ( )
3840 this . minimap = null
3941 this . editor = null
40- this . decorationsByMarkerId = { }
41- this . subscriptionsByMarkerId = { }
4242 }
4343
4444 changeVisible ( visible ) {
@@ -51,19 +51,9 @@ class MinimapFindAndReplaceBinding {
5151 }
5252
5353 clear ( ) {
54- const subscriptionsByMarkerIdKeys = Object . keys ( this . subscriptionsByMarkerId )
55- for ( let i = 0 , len = subscriptionsByMarkerIdKeys . length ; i < len ; i ++ ) {
56- const id = subscriptionsByMarkerIdKeys [ i ]
57- this . subscriptionsByMarkerId [ id ] . dispose ( )
58- delete this . subscriptionsByMarkerId [ id ]
59- }
60-
61- const decorationsByMarkerIdKeys = Object . keys ( this . decorationsByMarkerId )
62- for ( let i = 0 , len = decorationsByMarkerIdKeys . length ; i < len ; i ++ ) {
63- const id = decorationsByMarkerIdKeys [ i ]
64- this . decorationsByMarkerId [ id ] . destroy ( )
65- delete this . decorationsByMarkerId [ id ]
66- }
54+ this . disposeMarkerSubsctiotions ( )
55+ this . decorationsByMarkerId . clear ( )
56+ this . subscriptionsByMarkerId . clear ( )
6757 }
6858
6959 discoverMarkers ( ) {
@@ -93,15 +83,14 @@ class MinimapFindAndReplaceBinding {
9383 return
9484 }
9585
96- const {
97- id,
98- } = marker
99- this . decorationsByMarkerId [ id ] = decoration
100- this . subscriptionsByMarkerId [ id ] = decoration . onDidDestroy ( ( ) => {
101- this . subscriptionsByMarkerId [ id ] . dispose ( )
102- delete this . decorationsByMarkerId [ id ]
103- delete this . subscriptionsByMarkerId [ id ]
104- } )
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+ )
10594 }
10695
10796 findViewIsVisible ( ) {
0 commit comments