diff --git a/lib/buffer-search.js b/lib/buffer-search.js index c00671b2..e505c184 100644 --- a/lib/buffer-search.js +++ b/lib/buffer-search.js @@ -237,7 +237,7 @@ class BufferSearch { } } - this.emitter.emit('did-update', this.markers.slice()); + if (changes.length) this.emitter.emit('did-update', this.markers.slice()); this.currentResultMarker = null; this.setCurrentMarkerFromSelection(); } diff --git a/lib/find-view.coffee b/lib/find-view.coffee index 53aaaf51..be877412 100644 --- a/lib/find-view.coffee +++ b/lib/find-view.coffee @@ -307,7 +307,6 @@ class FindView extends View atom.beep() markersUpdated: (@markers) => - @findError = null @updateResultCounter() @updateReplaceEnablement() @@ -342,6 +341,8 @@ class FindView extends View @descriptionLabel.text(infoMessage).removeClass('text-error') setErrorMessage: (errorMessage) -> + this.removeClass('has-results') + this.addClass('has-no-results') @descriptionLabel.text(errorMessage).addClass('text-error') clearMessage: -> diff --git a/spec/find-view-spec.coffee b/spec/find-view-spec.coffee index 722c9ae9..1f5fc9ad 100644 --- a/spec/find-view-spec.coffee +++ b/spec/find-view-spec.coffee @@ -506,6 +506,29 @@ describe 'FindView', -> expect(findView.descriptionLabel).toHaveClass 'text-error' expect(findView.descriptionLabel.text()).toContain 'Invalid regular expression' + it "does not reset when the buffer is updated", -> + # This is a rather specific test: the error message only disappeared + # when there were no changes. Backspacing nothing can reproduce this, + # as well as saving or undoing and then redoing. + editor.setCursorBufferPosition([0, 0]) + # Since we're at the beginning of the file, backspacing will do nothing but still send a change event + editor.backspace() + advanceClock(editor.buffer.stoppedChangingDelay) + + expect(findView.descriptionLabel).toHaveClass 'text-error' + expect(findView.descriptionLabel.text()).toContain 'Invalid regular expression' + + it "adds the has-no-results class", -> + findView.findEditor.setText 'it' + atom.commands.dispatch(findView.findEditor.element, 'core:confirm') + expect(findView).toHaveClass 'has-results' + expect(findView).not.toHaveClass 'has-no-results' + + findView.findEditor.setText 'i[t' + atom.commands.dispatch(findView.findEditor.element, 'core:confirm') + expect(findView).toHaveClass 'has-no-results' + expect(findView).not.toHaveClass 'has-results' + it "will be reset when there is no longer an error", -> expect(findView.descriptionLabel).toHaveClass 'text-error'