revert function to use sync version
update spies
fix another test
MODIFY
lib/project-find-view.js
lib/project-find-view.js
@@ -368,18 +368,18 @@ class ProjectFindView {
return;
}
- return this.showResultPane().then(async () => {
+ return this.showResultPane().then(() => {
const pathsPattern = this.pathsEditor.getText();
const replacePattern = this.replaceEditor.getText();
const message = `This will replace '${findPattern}' with '${replacePattern}' ${_.pluralize(this.model.matchCount, 'time')} in ${_.pluralize(this.model.pathCount, 'file')}`;
- const { response } = await atom.confirm({
+ const buttonChosen = atom.confirm({
message: 'Are you sure you want to replace all?',
detailedMessage: message,
buttons: ['OK', 'Cancel']
});
- if (response === 0) {
+ if (buttonChosen === 0) {
this.clearMessages();
return this.model.replace(pathsPattern, replacePattern, this.model.getPaths());
}

MODIFY
spec/project-find-view-spec.js
spec/project-find-view-spec.js
@@ -1204,7 +1204,7 @@ describe(`ProjectFindView (ripgrep=${ripgrep})`, () => {
atom.project.setPaths([projectPath]);
atom.commands.dispatch(workspaceElement, 'project-find:show');
- spyOn(atom, 'confirm').andReturn({response:0});
+ spyOn(atom, 'confirm').andReturn(0);
});
describe("when the regex option is chosen", () => {
@@ -1310,7 +1310,7 @@ describe(`ProjectFindView (ripgrep=${ripgrep})`, () => {
describe("when the replace button is pressed", () => {
beforeEach(() => {
- spyOn(atom, 'confirm').andReturn({ response: 0 });
+ spyOn(atom, 'confirm').andReturn(0);
});
it("runs the search, and replaces all the matches", async () => {
@@ -1380,7 +1380,7 @@ describe(`ProjectFindView (ripgrep=${ripgrep})`, () => {
describe("when a search with no results has been run", () => {
beforeEach(async () => {
- spyOn(atom, 'confirm').andReturn({ response: 0 });
+ spyOn(atom, 'confirm').andReturn(0);
projectFindView.findEditor.setText('nopenotinthefile');
atom.commands.dispatch(projectFindView.element, 'core:confirm');
@@ -1412,7 +1412,7 @@ describe(`ProjectFindView (ripgrep=${ripgrep})`, () => {
});
it("messages the user when the search text has changed since that last search", () => {
- spyOn(atom, 'confirm').andReturn({ response: 0 });
+ spyOn(atom, 'confirm').andReturn(0);
spyOn(atom.workspace, 'scan').andCallThrough();
projectFindView.findEditor.setText('sort');
@@ -1428,7 +1428,7 @@ describe(`ProjectFindView (ripgrep=${ripgrep})`, () => {
});
it("replaces all the matches and updates the results view", async () => {
- spyOn(atom, 'confirm').andReturn({ response: 0 });
+ spyOn(atom, 'confirm').andReturn(0);
projectFindView.replaceEditor.setText('sunshine');
expect(projectFindView.errorMessages).not.toBeVisible();
@@ -1478,7 +1478,7 @@ describe(`ProjectFindView (ripgrep=${ripgrep})`, () => {
atom.commands.dispatch(projectFindView.element, 'core:confirm');
await searchPromise;
- spyOn(atom, 'confirm').andReturn({ response: 0 });
+ spyOn(atom, 'confirm').andReturn(0);
projectFindView.replaceEditor.setText('sunshine');
expect(projectFindView.errorMessages).not.toBeVisible();
@@ -1496,7 +1496,7 @@ describe(`ProjectFindView (ripgrep=${ripgrep})`, () => {
describe("when there is an error replacing", () => {
beforeEach(async () => {
- spyOn(atom, 'confirm').andReturn({ response: 0 });
+ spyOn(atom, 'confirm').andReturn(0);
projectFindView.findEditor.setText('items');
atom.commands.dispatch(projectFindView.element, 'project-find:confirm');
await searchPromise;

revert function to use sync version

update spies

fix another test