Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Populate the find editor with selected text
Browse files Browse the repository at this point in the history
When it's empty. We assume the user wants to search for the selected 
text.

See #93
  • Loading branch information
benogle committed Dec 9, 2013
1 parent 2d813e9 commit 3a3af4a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/find-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ class FindView extends View
atom.workspaceView.command 'find-and-replace:replace-all', @replaceAll

showFind: =>
unless @findEditor.getText()
editorView = atom.workspaceView.getActiveView()
@findEditor.setText(editorView.getSelectedText()) if editorView

@attach() if not @hasParent()
@findEditor.focus()
@findEditor.selectAll()
Expand Down
13 changes: 13 additions & 0 deletions spec/find-view-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ describe 'FindView', ->
editor.trigger 'find-and-replace:show'
expect(atom.workspaceView.find('.find-and-replace')).toExist()

it "populates the findEditor with selection when there is a selection", ->
editor.setSelectedBufferRange([[2, 8], [2, 13]])
editor.trigger 'find-and-replace:show'
expect(atom.workspaceView.find('.find-and-replace')).toExist()
expect(findView.findEditor.getText()).toBe('items')

findView.findEditor.setText('')

editor.setSelectedBufferRange([[2, 14], [2, 20]])
editor.trigger 'find-and-replace:show'
expect(atom.workspaceView.find('.find-and-replace')).toExist()
expect(findView.findEditor.getText()).toBe('length')

describe "when FindView's replace editor is visible", ->
it "keeps the replace editor visible when find-and-replace:show is triggered", ->
editor.trigger 'find-and-replace:show-replace'
Expand Down

0 comments on commit 3a3af4a

Please sign in to comment.