Fix exeption when toggling invalid regex option as first search
MODIFY
lib/find-view.coffee
lib/find-view.coffee
@@ -371,7 +371,7 @@ class FindView extends View
firstMarkerIndexAfterCursor: (indexIncluded=false) ->
editor = @model.getEditor()
- return null unless editor
+ return null unless editor and @markers?.length > 0
selection = editor.getLastSelection()
{start, end} = selection.getBufferRange()

MODIFY
spec/find-view-spec.coffee
spec/find-view-spec.coffee
@@ -1222,6 +1222,16 @@ describe 'FindView', ->
atom.commands.dispatch(findView.findEditor.element, 'core:confirm')
expect(getResultDecorations(editor, 'find-result')).toHaveLength 0
+ it "doesn't throw an exception when toggling the regex option with an invalid pattern before performing any other search (regression)", ->
+ atom.commands.dispatch editorView, 'find-and-replace:show'
+
+ waitsForPromise ->
+ activationPromise
+
+ runs ->
+ findView.findEditor.setText '('
+ atom.commands.dispatch(findView.findEditor.element, 'find-and-replace:toggle-regex-option')
+
describe "replacing", ->
beforeEach ->
editor.setCursorBufferPosition([2, 0])

Fix exeption when toggling invalid regex option as first search