diff --git a/spec/workspace-spec.js b/spec/workspace-spec.js index bdd5677c8..476a4ba5b 100644 --- a/spec/workspace-spec.js +++ b/spec/workspace-spec.js @@ -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', () => { diff --git a/src/workspace.js b/src/workspace.js index 3bf112461..17c6b2a8b 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -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(