Fix replace on open buffers. only replace paths specified.

Closes find-and-replace#85
This commit is contained in:
Ben Ogle 2013-11-26 17:08:21 -08:00
parent 65746521a6
commit 46f73d037f
2 changed files with 14 additions and 0 deletions

View File

@ -353,6 +353,19 @@ describe "Project", ->
expect(editor.isModified()).toBeFalsy()
it "does not replace when the path is not specified", ->
editor = atom.project.openSync('sample.js')
editor = atom.project.openSync('sample-with-comments.js')
results = []
waitsForPromise ->
atom.project.replace /items/gi, 'items', [commentFilePath], (result) ->
results.push(result)
runs ->
expect(results).toHaveLength 1
expect(results[0].filePath).toBe commentFilePath
it "does NOT save when modified", ->
editor = atom.project.openSync('sample.js')
editor.buffer.change([[0,0],[0,0]], 'omg')

View File

@ -333,6 +333,7 @@ class Project extends telepath.Model
task.on 'replace:path-replaced', iterator
for buffer in @buffers.getValues()
continue unless buffer.getPath() in filePaths
replacements = buffer.replace(regex, replacementText, iterator)
iterator({filePath: buffer.getPath(), replacements}) if replacements