1
1
const _ = require ( 'underscore-plus' ) ;
2
- const { TextBuffer , TextEditor, CompositeDisposable} = require ( 'atom' ) ;
2
+ const { TextEditor, CompositeDisposable} = require ( 'atom' ) ;
3
3
const Util = require ( './project/util' ) ;
4
4
const etch = require ( 'etch' ) ;
5
5
const $ = etch . dom ;
@@ -211,7 +211,7 @@ class FindView {
211
211
212
212
didHide ( ) {
213
213
this . hideAllTooltips ( ) ;
214
- let workspaceElement = atom . views . getView ( atom . workspace ) ;
214
+ const workspaceElement = atom . views . getView ( atom . workspace ) ;
215
215
workspaceElement . focus ( ) ;
216
216
workspaceElement . classList . remove ( 'find-visible' ) ;
217
217
}
@@ -223,7 +223,7 @@ class FindView {
223
223
224
224
handleEvents ( ) {
225
225
this . findEditor . onDidStopChanging ( ( ) => this . liveSearch ( ) ) ;
226
- this . refs . nextButton . addEventListener ( 'click' , e => e . shiftKey ? this . findPrevious ( { focusEditorAfter : true } ) : this . findNext ( { focusEditorAfter : true } ) ) ;
226
+ this . refs . nextButton . addEventListener ( 'click' , e => ( e . shiftKey ? this . findPrevious ( { focusEditorAfter : true } ) : this . findNext ( { focusEditorAfter : true } ) ) ) ;
227
227
this . refs . findAllButton . addEventListener ( 'click' , this . findAll . bind ( this ) ) ;
228
228
this . subscriptions . add ( atom . commands . add ( 'atom-workspace' , {
229
229
'find-and-replace:find-next' : ( ) => this . findNext ( { focusEditorAfter : true } ) ,
@@ -235,7 +235,7 @@ class FindView {
235
235
'find-and-replace:use-selection-as-replace-pattern' : this . setSelectionAsReplacePattern . bind ( this )
236
236
} ) ) ;
237
237
238
- this . refs . replaceNextButton . addEventListener ( 'click' , e => e . shiftKey ? this . replacePrevious ( ) : this . replaceNext ( ) ) ;
238
+ this . refs . replaceNextButton . addEventListener ( 'click' , e => ( e . shiftKey ? this . replacePrevious ( ) : this . replaceNext ( ) ) ) ;
239
239
this . refs . replaceAllButton . addEventListener ( 'click' , this . replaceAll . bind ( this ) ) ;
240
240
this . subscriptions . add ( atom . commands . add ( 'atom-workspace' , {
241
241
'find-and-replace:replace-previous' : this . replacePrevious . bind ( this ) ,
@@ -279,7 +279,7 @@ class FindView {
279
279
this . element . addEventListener ( 'focus' , ( ) => this . findEditor . element . focus ( ) ) ;
280
280
this . element . addEventListener ( 'click' , ( e ) => {
281
281
if ( e . target . tagName === 'button' ) {
282
- let workspaceElement = atom . views . getView ( atom . workspace ) ;
282
+ const workspaceElement = atom . views . getView ( atom . workspace ) ;
283
283
workspaceElement . focus ( ) ;
284
284
}
285
285
} ) ;
@@ -325,7 +325,7 @@ class FindView {
325
325
}
326
326
327
327
liveSearch ( ) {
328
- let findPattern = this . findEditor . getText ( ) ;
328
+ const findPattern = this . findEditor . getText ( ) ;
329
329
if ( findPattern . length === 0 || ( findPattern . length >= atom . config . get ( 'find-and-replace.liveSearchMinimumCharacters' ) && ! this . model . patternMatchesEmptyString ( findPattern ) ) ) {
330
330
return this . model . search ( findPattern ) ;
331
331
}
@@ -361,7 +361,7 @@ class FindView {
361
361
if ( fieldToFocus ) {
362
362
fieldToFocus . getElement ( ) . focus ( ) ;
363
363
} else if ( focusEditorAfter ) {
364
- let workspaceElement = atom . views . getView ( atom . workspace ) ;
364
+ const workspaceElement = atom . views . getView ( atom . workspace ) ;
365
365
workspaceElement . focus ( ) ;
366
366
} else {
367
367
this . findEditor . getElement ( ) . focus ( ) ;
@@ -387,7 +387,7 @@ class FindView {
387
387
if ( this . markers && this . markers . length > 0 ) {
388
388
let currentMarker = this . model . currentResultMarker ;
389
389
if ( ! currentMarker ) {
390
- let position = this [ nextIndexFn ] ( ) ;
390
+ const position = this [ nextIndexFn ] ( ) ;
391
391
if ( position ) {
392
392
currentMarker = this . markers [ position . index ] ;
393
393
}
@@ -419,8 +419,8 @@ class FindView {
419
419
this . updateReplaceEnablement ( ) ;
420
420
421
421
if ( this . model . getFindOptions ( ) . findPattern ) {
422
- let results = this . markers . length ;
423
- let resultsStr = results ? _ . pluralize ( results , 'result' ) : 'No results' ;
422
+ const results = this . markers . length ;
423
+ const resultsStr = results ? _ . pluralize ( results , 'result' ) : 'No results' ;
424
424
this . element . classList . remove ( 'has-results' , 'has-no-results' ) ;
425
425
this . element . classList . add ( results ? 'has-results' : 'has-no-results' ) ;
426
426
this . setInfoMessage ( `${ resultsStr } found for '${ this . model . getFindOptions ( ) . findPattern } '` ) ;
@@ -472,23 +472,23 @@ class FindView {
472
472
}
473
473
474
474
selectFirstMarkerAfterCursor ( ) {
475
- let marker = this . firstMarkerIndexAfterCursor ( ) ;
475
+ const marker = this . firstMarkerIndexAfterCursor ( ) ;
476
476
if ( ! marker ) { return ; }
477
- let { index, wrapped} = marker ;
477
+ const { index, wrapped} = marker ;
478
478
this . selectMarkerAtIndex ( index , wrapped ) ;
479
479
}
480
480
481
481
selectFirstMarkerStartingFromCursor ( ) {
482
- let marker = this . firstMarkerIndexAfterCursor ( true ) ;
482
+ const marker = this . firstMarkerIndexAfterCursor ( true ) ;
483
483
if ( ! marker ) { return ; }
484
- let { index, wrapped} = marker ;
484
+ const { index, wrapped} = marker ;
485
485
this . selectMarkerAtIndex ( index , wrapped ) ;
486
486
}
487
487
488
488
selectFirstMarkerBeforeCursor ( ) {
489
- let marker = this . firstMarkerIndexBeforeCursor ( ) ;
489
+ const marker = this . firstMarkerIndexBeforeCursor ( ) ;
490
490
if ( ! marker ) { return ; }
491
- let { index, wrapped} = marker ;
491
+ const { index, wrapped} = marker ;
492
492
this . selectMarkerAtIndex ( index , wrapped ) ;
493
493
}
494
494
@@ -541,10 +541,10 @@ class FindView {
541
541
542
542
selectAllMarkers ( ) {
543
543
if ( ! this . markers || this . markers . length === 0 ) return ;
544
- let ranges = ( Array . from ( this . markers ) . map ( ( marker ) => marker . getBufferRange ( ) ) ) ;
545
- let scrollMarker = this . markers [ this . firstMarkerIndexAfterCursor ( ) . index ] ;
546
- let editor = this . model . getEditor ( ) ;
547
- for ( let range of ranges ) {
544
+ const ranges = ( Array . from ( this . markers ) . map ( ( marker ) => marker . getBufferRange ( ) ) ) ;
545
+ const scrollMarker = this . markers [ this . firstMarkerIndexAfterCursor ( ) . index ] ;
546
+ const editor = this . model . getEditor ( ) ;
547
+ for ( const range of ranges ) {
548
548
editor . unfoldBufferRow ( range . start . row ) ;
549
549
}
550
550
editor . setSelectedBufferRanges ( ranges , { flash : true } ) ;
@@ -556,9 +556,9 @@ class FindView {
556
556
if ( ! this . markers || this . markers . length === 0 ) return ;
557
557
558
558
if ( marker = this . markers [ markerIndex ] ) {
559
- let editor = this . model . getEditor ( ) ;
560
- let bufferRange = marker . getBufferRange ( ) ;
561
- let screenRange = marker . getScreenRange ( ) ;
559
+ const editor = this . model . getEditor ( ) ;
560
+ const bufferRange = marker . getBufferRange ( ) ;
561
+ const screenRange = marker . getScreenRange ( ) ;
562
562
563
563
if (
564
564
screenRange . start . row < editor . getFirstVisibleScreenRow ( ) ||
@@ -581,7 +581,7 @@ class FindView {
581
581
}
582
582
583
583
setSelectionAsFindPattern ( ) {
584
- let editor = this . model . getEditor ( ) ;
584
+ const editor = this . model . getEditor ( ) ;
585
585
if ( editor && editor . getSelectedText ) {
586
586
let findPattern = editor . getSelectedText ( ) || editor . getWordUnderCursor ( ) ;
587
587
if ( this . model . getFindOptions ( ) . useRegex ) {
@@ -598,7 +598,7 @@ class FindView {
598
598
}
599
599
600
600
setSelectionAsReplacePattern ( ) {
601
- let editor = this . model . getEditor ( ) ;
601
+ const editor = this . model . getEditor ( ) ;
602
602
if ( editor && editor . getSelectedText ) {
603
603
let replacePattern = editor . getSelectedText ( ) || editor . getWordUnderCursor ( ) ;
604
604
if ( this . model . getFindOptions ( ) . useRegex ) {
@@ -678,7 +678,7 @@ class FindView {
678
678
}
679
679
680
680
anyMarkersAreSelected ( ) {
681
- let editor = this . model . getEditor ( ) ;
681
+ const editor = this . model . getEditor ( ) ;
682
682
if ( editor ) {
683
683
return editor . getSelectedBufferRanges ( ) . some ( selectedRange => {
684
684
return this . model . findMarker ( selectedRange ) ;
@@ -703,7 +703,7 @@ class FindView {
703
703
toggleSelectionOption ( ) {
704
704
this . search ( { inCurrentSelection : ! this . model . getFindOptions ( ) . inCurrentSelection } ) ;
705
705
706
- let editor = this . model . getEditor ( ) ;
706
+ const editor = this . model . getEditor ( ) ;
707
707
if ( editor && editor . getSelectedBufferRanges ( ) . every ( range => range . isEmpty ( ) ) ) {
708
708
this . selectFirstMarkerAfterCursor ( ) ;
709
709
}
@@ -717,9 +717,9 @@ class FindView {
717
717
}
718
718
719
719
updateFindEnablement ( ) {
720
- let editor = this . model . getEditor ( ) ;
721
- let isDisabled = this . refs . findAllButton . classList . contains ( 'disabled' ) ;
722
- let hadFindTooltip = ! ! this . findTooltipSubscriptions ;
720
+ const editor = this . model . getEditor ( ) ;
721
+ const isDisabled = this . refs . findAllButton . classList . contains ( 'disabled' ) ;
722
+ const hadFindTooltip = Boolean ( this . findTooltipSubscriptions ) ;
723
723
724
724
if ( hadFindTooltip ) this . findTooltipSubscriptions . dispose ( ) ;
725
725
this . findTooltipSubscriptions = new CompositeDisposable ;
@@ -752,7 +752,7 @@ class FindView {
752
752
}
753
753
754
754
updateReplaceEnablement ( ) {
755
- let canReplace = this . markers && this . markers . length > 0 ;
755
+ const canReplace = this . markers && this . markers . length > 0 ;
756
756
if ( canReplace && ! this . refs . replaceAllButton . classList . contains ( 'disabled' ) ) return ;
757
757
758
758
if ( this . replaceTooltipSubscriptions ) this . replaceTooltipSubscriptions . dispose ( ) ;
@@ -791,10 +791,10 @@ class FindView {
791
791
792
792
showWrapIcon ( icon ) {
793
793
if ( ! atom . config . get ( 'find-and-replace.showSearchWrapIcon' ) ) return ;
794
- let editor = this . model . getEditor ( ) ;
794
+ const editor = this . model . getEditor ( ) ;
795
795
if ( ! editor ) return ;
796
796
797
- let editorView = atom . views . getView ( editor ) ;
797
+ const editorView = atom . views . getView ( editor ) ;
798
798
if ( ! editorView . parentNode ) return ;
799
799
editorView . parentNode . appendChild ( this . wrapIcon ) ;
800
800
0 commit comments