Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Keep query and replace text when switching between Replace and Replace In Files #9601

Merged
merged 4 commits into from
Oct 21, 2014

Conversation

marcelgerber
Copy link
Contributor

For #8531

@marcelgerber marcelgerber changed the title Keep query and replace text when switching between Replace and Replace I... Keep query and replace text when switching between Replace and Replace In Files Oct 20, 2014
@redmunds redmunds self-assigned this Oct 21, 2014
} else {
initialQuery = FindUtils.getInitialQueryFromSelection(editor);
var openedFindbars = FindBar._bars && FindBar._bars.filter(function (findBar) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findBar is already used in module scope, so change it in this inner scope to something like bar to make code easier to read.

@redmunds
Copy link
Contributor

@marcelgerber This looks good. Just a couple minor comments.

@marcelgerber
Copy link
Contributor Author

I wonder if we should put these lines into FindUtils to reduce code duplication?

@marcelgerber
Copy link
Contributor Author

@redmunds Could you take another look?

query = currentFindBar.getQueryInfo().query;
replaceText = currentFindBar.getReplaceText();
} else {
var openedFindbars = FindBar._bars && FindBar._bars.filter(function (bar) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're only interested in the first non-closed bar, you should use FindBar._bars.some() which quits the loop when first one is found (but filter() unnecessarily continues through entire Array).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used _.find() as Array.filter will only return a boolean value...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool -- even better. With Array.some(), you have to create a var in outer scope to save item.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and that's why I didn't use it :D

@redmunds
Copy link
Contributor

@marcelgerber Nice refactoring! Just 1 more comment.

@marcelgerber
Copy link
Contributor Author

@redmunds Time for the final review

@redmunds
Copy link
Contributor

Looks good. Merging.

redmunds added a commit that referenced this pull request Oct 21, 2014
Keep query and replace text when switching between Replace and Replace In Files
@redmunds redmunds merged commit 451fd32 into adobe:master Oct 21, 2014
@marcelgerber marcelgerber deleted the find-keep-query branch October 21, 2014 17:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants