Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/fuzzy-finder-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class FuzzyFinderView extends SelectListView
getFilterKey: ->
'projectRelativePath'

cancel: ->
if atom.config.get('fuzzy-finder.preserveLastSearch')
lastSearch = @getFilterQuery()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling @getFilterQuery() returns the filter text without a trailing line number so pack:8 would become pack.

Did you want to preserve this info across opens? A trailing :NUMBER allows you to open a file to a specific line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should ship this as-is to start, can always tweak it later.

super

@filterEditorView.setText(lastSearch)
@filterEditorView.getModel().selectAll()
else
super

destroy: ->
@cancel()
@panel?.destroy()
Expand Down
3 changes: 3 additions & 0 deletions lib/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ module.exports =
description: "Whether to search through all open panes or just the active one. Holding shift inverts this setting."
type: 'boolean'
default: false
preserveLastSearch:
type: 'boolean'
default: false

activate: (state) ->
@active = true
Expand Down
27 changes: 27 additions & 0 deletions spec/fuzzy-finder-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,33 @@ describe 'FuzzyFinder', ->
expect(atom.workspace.getActiveTextEditor().getPath()).toBe editor1.getPath()
expect(atom.workspace.getActiveTextEditor().getCursorBufferPosition()).toEqual [3, 4]

describe "Preserve last search", ->
it "does not preserve last search by default", ->
dispatchCommand('toggle-file-finder')
expect(atom.workspace.panelForItem(projectView).isVisible()).toBe true
projectView.filterEditorView.getModel().insertText('this should not show up next time we open finder')

dispatchCommand('toggle-file-finder')
expect(atom.workspace.panelForItem(projectView).isVisible()).toBe false

dispatchCommand('toggle-file-finder')
expect(atom.workspace.panelForItem(projectView).isVisible()).toBe true
expect(projectView.filterEditorView.getText()).toBe ''

it "preserves last search when config is set", ->
atom.config.set("fuzzy-finder.preserveLastSearch", true)

dispatchCommand('toggle-file-finder')
expect(atom.workspace.panelForItem(projectView).isVisible()).toBe true
projectView.filterEditorView.getModel().insertText('this should show up next time we open finder')

dispatchCommand('toggle-file-finder')
expect(atom.workspace.panelForItem(projectView).isVisible()).toBe false

dispatchCommand('toggle-file-finder')
expect(atom.workspace.panelForItem(projectView).isVisible()).toBe true
expect(projectView.filterEditorView.getText()).toBe 'this should show up next time we open finder'

describe "Git integration", ->
[projectPath, gitRepository, gitDirectory] = []

Expand Down