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

Commit 3c695c4

Browse files
committed
Fix regression on previous spec, add in spec for new functionality in show-in-current-directory (very little needed)
1 parent 79e9331 commit 3c695c4

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

lib/project-find-view.coffee

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ class ProjectFindView extends View
274274
@model.replace(pathsPattern, replacePattern, @model.getPaths())
275275

276276
directoryPathForElement: (element) ->
277-
if element?.dataset.path
278-
elementPath = element?.querySelector('[data-path]')?.dataset.path
277+
elementPath = element?.dataset.path ? element?.querySelector('[data-path]')?.dataset.path
279278

280279
# Traverse up the DOM if the element and its children don't have a path
281280
unless elementPath

spec/project-find-view-spec.coffee

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,42 @@ describe 'ProjectFindView', ->
127127
expect(projectFindView.regexOptionButton).toHaveClass 'selected'
128128
expect(projectFindView.wholeWordOptionButton).toHaveClass 'selected'
129129

130+
describe "when project-find:show-in-current-directory is triggered with an open buffer", ->
131+
editor = null
132+
133+
beforeEach ->
134+
atom.project.setPaths([__dirname])
135+
atom.commands.dispatch(workspaceElement, 'project-find:show')
136+
137+
waitsForPromise ->
138+
activationPromise
139+
140+
runs ->
141+
projectFindView.findEditor.setText('')
142+
projectFindView.pathsEditor.setText('')
143+
144+
waitsForPromise ->
145+
atom.workspace.open('fixtures/sample.js').then (o) -> editor = o
146+
147+
it "calls project-find:show, and populates both findEditor and pathsEditor when there is a selection", ->
148+
editor.setSelectedBufferRange([[3, 8], [3, 13]])
149+
atom.commands.dispatch(workspaceElement, 'project-find:show-in-current-directory')
150+
expect(getAtomPanel()).toBeVisible()
151+
expect(projectFindView.findEditor.getText()).toBe('pivot')
152+
expect(projectFindView.pathsEditor.getText()).toBe('fixtures')
153+
154+
editor.setSelectedBufferRange([[2, 14], [2, 20]])
155+
atom.commands.dispatch(workspaceElement, 'project-find:show-in-current-directory')
156+
expect(getAtomPanel()).toBeVisible()
157+
expect(projectFindView.findEditor.getText()).toBe('length')
158+
expect(projectFindView.pathsEditor.getText()).toBe('fixtures')
159+
160+
it "calls project-find:show, and populates only pathsEditor when there is no selection", ->
161+
atom.commands.dispatch(workspaceElement, 'project-find:show-in-current-directory')
162+
expect(getAtomPanel()).toBeVisible()
163+
expect(projectFindView.findEditor.getText()).toBe('')
164+
expect(projectFindView.pathsEditor.getText()).toBe('fixtures')
165+
130166
describe "when project-find:toggle is triggered", ->
131167
it "toggles the visibility of the ProjectFindView", ->
132168
atom.commands.dispatch(workspaceElement, 'project-find:toggle')

0 commit comments

Comments
 (0)