Merge pull request #15224 from atom/wl-multiline-is-important

Set multiline flags for out-of-Atom regex replacements
This commit is contained in:
Wliu
2017-08-10 14:15:50 -04:00
committed by GitHub
2 changed files with 17 additions and 0 deletions

View File

@@ -2394,6 +2394,22 @@ i = /test/; #FIXME\
expect(results[0].replacements).toBe(6)
})
})
it('does not discard the multiline flag', () => {
const filePath = path.join(projectDir, 'sample.js')
fs.copyFileSync(path.join(fixturesDir, 'sample.js'), filePath)
const results = []
waitsForPromise(() =>
atom.workspace.replace(/;$/gmi, 'items', [filePath], result => results.push(result))
)
runs(() => {
expect(results).toHaveLength(1)
expect(results[0].filePath).toBe(filePath)
expect(results[0].replacements).toBe(8)
})
})
})
describe('when a buffer is already open', () => {

View File

@@ -1950,6 +1950,7 @@ module.exports = class Workspace extends Model {
if (!outOfProcessFinished.length) {
let flags = 'g'
if (regex.multiline) { flags += 'm' }
if (regex.ignoreCase) { flags += 'i' }
const task = Task.once(