mirror of
https://github.com/atom/atom.git
synced 2026-02-16 09:35:54 -05:00
Reuse search when re-toggling find in project
Previously the prior find in file search was thrown away when toggling find-in-project subsequent times. Now the previous search text is retained and selected when toggled.
This commit is contained in:
@@ -43,7 +43,7 @@ class CommandPanelView extends View
|
||||
@subscribeToCommand rootView, 'command-panel:toggle', => @toggle()
|
||||
@subscribeToCommand rootView, 'command-panel:toggle-preview', => @togglePreview()
|
||||
@subscribeToCommand rootView, 'command-panel:find-in-file', => @findInFile()
|
||||
@subscribeToCommand rootView, 'command-panel:find-in-project', => @attach('Xx/')
|
||||
@subscribeToCommand rootView, 'command-panel:find-in-project', => @findInProject()
|
||||
@subscribeToCommand rootView, 'command-panel:repeat-relative-address', => @repeatRelativeAddress()
|
||||
@subscribeToCommand rootView, 'command-panel:repeat-relative-address-in-reverse', => @repeatRelativeAddress(reverse: true)
|
||||
@subscribeToCommand rootView, 'command-panel:set-selection-as-regex-address', => @setSelectionAsLastRelativeAddress()
|
||||
@@ -123,6 +123,13 @@ class CommandPanelView extends View
|
||||
else
|
||||
@attach('/')
|
||||
|
||||
findInProject: ->
|
||||
if @miniEditor.getText().indexOf('Xx/') is 0
|
||||
@attach()
|
||||
@miniEditor.setSelectedBufferRange([[0, 3], [0, Infinity]])
|
||||
else
|
||||
@attach('Xx/')
|
||||
|
||||
escapedCommand: ->
|
||||
@miniEditor.getText()
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ describe "CommandPanel", ->
|
||||
expect(commandPanel.miniEditor.getCursorBufferPosition()).toEqual [0, 1]
|
||||
|
||||
describe "when the command panel's editor begins with /", ->
|
||||
it "selects text text after the /", ->
|
||||
it "selects text after the /", ->
|
||||
spyOn(commandPanel, 'attach').andCallThrough()
|
||||
commandPanel.miniEditor.setText("/foo")
|
||||
commandPanel.miniEditor.setCursorBufferPosition([0, 0])
|
||||
@@ -324,16 +324,29 @@ describe "CommandPanel", ->
|
||||
expect(commandPanel.miniEditor.getSelectedText()).toBe "foo"
|
||||
|
||||
describe "when command-panel:find-in-project is triggered on the root view", ->
|
||||
it "pre-populates the command panel's editor with Xx/ and moves the cursor to the last column", ->
|
||||
spyOn(commandPanel, 'attach').andCallThrough()
|
||||
commandPanel.miniEditor.setText("foo")
|
||||
commandPanel.miniEditor.setCursorBufferPosition([0, 0])
|
||||
describe "when the command panel's editor does not begin with Xx/", ->
|
||||
it "pre-populates the command panel's editor with Xx/ and moves the cursor to the last column", ->
|
||||
spyOn(commandPanel, 'attach').andCallThrough()
|
||||
commandPanel.miniEditor.setText("foo")
|
||||
commandPanel.miniEditor.setCursorBufferPosition([0, 0])
|
||||
|
||||
rootView.trigger "command-panel:find-in-project"
|
||||
expect(commandPanel.attach).toHaveBeenCalled()
|
||||
expect(commandPanel.parent).not.toBeEmpty()
|
||||
expect(commandPanel.miniEditor.getText()).toBe "Xx/"
|
||||
expect(commandPanel.miniEditor.getCursorBufferPosition()).toEqual [0, 3]
|
||||
rootView.trigger "command-panel:find-in-project"
|
||||
expect(commandPanel.attach).toHaveBeenCalled()
|
||||
expect(commandPanel.parent).not.toBeEmpty()
|
||||
expect(commandPanel.miniEditor.getText()).toBe "Xx/"
|
||||
expect(commandPanel.miniEditor.getCursorBufferPosition()).toEqual [0, 3]
|
||||
|
||||
describe "when the command panel's editor begins with Xx/", ->
|
||||
it "selects text after the Xx/", ->
|
||||
spyOn(commandPanel, 'attach').andCallThrough()
|
||||
commandPanel.miniEditor.setText("Xx/foo")
|
||||
commandPanel.miniEditor.setCursorBufferPosition([0, 0])
|
||||
|
||||
rootView.getActiveView().trigger "command-panel:find-in-project"
|
||||
expect(commandPanel.attach).toHaveBeenCalled()
|
||||
expect(commandPanel.parent).not.toBeEmpty()
|
||||
expect(commandPanel.miniEditor.getText()).toBe "Xx/foo"
|
||||
expect(commandPanel.miniEditor.getSelectedText()).toBe "foo"
|
||||
|
||||
describe "when return is pressed on the panel's editor", ->
|
||||
describe "if the command has an immediate effect", ->
|
||||
|
||||
Reference in New Issue
Block a user