Fix duplicate command registration for `find-and-replace:find-all`
Also, inline `handleFindEvents` and `handleReplaceEvents` methods, which
made the duplicate registration less obvious.
Fixes
MODIFY
lib/find-view.js
lib/find-view.js
@@ -231,14 +231,30 @@ class FindView {
}
handleEvents() {
- this.handleFindEvents();
- this.handleReplaceEvents();
+ this.findEditor.onDidStopChanging(() => this.liveSearch());
+ this.refs.nextButton.addEventListener('click', e => e.shiftKey ? this.findPrevious({focusEditorAfter: true}) : this.findNext({focusEditorAfter: true}));
+ this.refs.findAllButton.addEventListener('click', this.findAll.bind(this));
+ this.subscriptions.add(atom.commands.add('atom-workspace', {
+ 'find-and-replace:find-next': () => this.findNext({focusEditorAfter: true}),
+ 'find-and-replace:find-previous': () => this.findPrevious({focusEditorAfter: true}),
+ 'find-and-replace:find-all': () => this.findAll({focusEditorAfter: true}),
+ 'find-and-replace:find-next-selected': this.findNextSelected.bind(this),
+ 'find-and-replace:find-previous-selected': this.findPreviousSelected.bind(this),
+ 'find-and-replace:use-selection-as-find-pattern': this.setSelectionAsFindPattern.bind(this)
+ }));
+
+ this.refs.replaceNextButton.addEventListener('click', this.replaceNext.bind(this));
+ this.refs.replaceAllButton.addEventListener('click', this.replaceAll.bind(this));
+ this.subscriptions.add(atom.commands.add('atom-workspace', {
+ 'find-and-replace:replace-previous': this.replacePrevious.bind(this),
+ 'find-and-replace:replace-next': this.replaceNext.bind(this),
+ 'find-and-replace:replace-all': this.replaceAll.bind(this),
+ }));
this.subscriptions.add(atom.commands.add(this.findEditor.element, {
'core:confirm': () => this.confirm(),
'find-and-replace:confirm': () => this.confirm(),
- 'find-and-replace:show-previous': () => this.showPrevious(),
- 'find-and-replace:find-all': () => this.findAll()
+ 'find-and-replace:show-previous': () => this.showPrevious()
}));
this.subscriptions.add(atom.commands.add(this.replaceEditor.element, {
@@ -276,30 +292,6 @@ class FindView {
});
}
- handleFindEvents() {
- this.findEditor.onDidStopChanging(() => this.liveSearch());
- this.refs.nextButton.addEventListener('click', e => e.shiftKey ? this.findPrevious({focusEditorAfter: true}) : this.findNext({focusEditorAfter: true}));
- this.refs.findAllButton.addEventListener('click', this.findAll.bind(this));
- this.subscriptions.add(atom.commands.add('atom-workspace', {
- 'find-and-replace:find-next': () => this.findNext({focusEditorAfter: true}),
- 'find-and-replace:find-previous': () => this.findPrevious({focusEditorAfter: true}),
- 'find-and-replace:find-all': () => this.findAll({focusEditorAfter: true}),
- 'find-and-replace:find-next-selected': this.findNextSelected.bind(this),
- 'find-and-replace:find-previous-selected': this.findPreviousSelected.bind(this),
- 'find-and-replace:use-selection-as-find-pattern': this.setSelectionAsFindPattern.bind(this)
- }));
- }
-
- handleReplaceEvents() {
- this.refs.replaceNextButton.addEventListener('click', this.replaceNext.bind(this));
- this.refs.replaceAllButton.addEventListener('click', this.replaceAll.bind(this));
- this.subscriptions.add(atom.commands.add('atom-workspace', {
- 'find-and-replace:replace-previous': this.replacePrevious.bind(this),
- 'find-and-replace:replace-next': this.replaceNext.bind(this),
- 'find-and-replace:replace-all': this.replaceAll.bind(this),
- }));
- }
-
focusFindEditor() {
const activeEditor = atom.workspace.getCenter().getActiveTextEditor()
let selectedText = activeEditor && activeEditor.getSelectedText()

Fix duplicate command registration for `find-and-replace:find-all`

Also, inline `handleFindEvents` and `handleReplaceEvents` methods, which 
made the duplicate registration less obvious.

Fixes #1034