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

Replace $& with the whole match #5929

Merged
merged 6 commits into from
Jan 30, 2014

Conversation

marcelgerber
Copy link
Contributor

Implements the same special replacement patterns as in the Mozilla Reference.
See this little conversation: #5840 (comment)

Includes Unit tests.

@ghost ghost assigned njx Nov 11, 2013
@njx
Copy link

njx commented Dec 3, 2013

Hi - sorry I haven't gotten to this, been busy with non-Brackets stuff (and the holidays :)) I might not be able to get to it until the next sprint.

@marcelgerber
Copy link
Contributor Author

@njx Would you mind reviewing this? Are there any changes to make?

@njx
Copy link

njx commented Jan 10, 2014

Sorry, my time has been crunched. Let me find someone else who can review it next week.

@njx
Copy link

njx commented Jan 10, 2014

Unassigning so we can look at reassigning it next week

@marcelgerber
Copy link
Contributor Author

Seems like you forgot to re-assign this @njx. Sorry, but I don't want it to be lost ;)

@njx
Copy link

njx commented Jan 21, 2014

No, haven't forgotten. We're trying to finish out the sprint (a bit late due to some issues with file watchers) and so we aren't picking up other pull requests right now. Hopefully we'll get back to it in a few days. Sorry!

@ghost ghost assigned lkcampbell Jan 24, 2014
@kkarlesk
Copy link
Contributor

@lkcampbell Would you please take a look at this one?

@lkcampbell
Copy link
Contributor

@SAplayer, the parsing code appears to be correct.

I guess one of the things I don't understand is why we have to write our own parsing code for the dollar sign combinations if the Javascript engine already knows how to parse these patterns. Is there a way we could just have Javascript do that work for us?

@lkcampbell
Copy link
Contributor

I guess I should pose the question for @njx as well since it looks like both of you did a lot of work on the dollar sign fixes. Why are we parsing regexps that contain dollar signs manually if JavaScript already understands how to parse them?

@marcelgerber
Copy link
Contributor Author

@njx Answered this question himself in #5840: #5840 (comment)

@njx
Copy link

njx commented Jan 27, 2014

Thanks for digging that up @SAplayer - I had forgotten the reason :)

@njx
Copy link

njx commented Jan 27, 2014

(But there might be some clever way to do it that I hadn't thought of... @lkcampbell if you come up with one, let us know :) )

@lkcampbell
Copy link
Contributor

@njx, I think you guys are correct, we may be losing the context of the match that allows the replacement code to work. Still, I will play around with it a little more today and see if there is another approach.

If nothing else, we should come up with a good comment to document the solution so we don't keep asking this same question every time we look at the code. But until I understand the problem a bit better, I don't know exactly what the comment is going to be.

@marcelgerber
Copy link
Contributor Author

Maybe something like this?

FUTURE: Maybe try to use the JavaScript replace() function to do all parsing logic.

@njx
Copy link

njx commented Jan 28, 2014

If we don't actually have an idea for how to do it, I think the comment should just explain why we think we can't - e.g. "Note that we can't just use the ordinary replace() function here, because the string has been extracted from the original text and so might be missing some context that the regexp matched."

@lkcampbell
Copy link
Contributor

Sounds good to me for now. I haven't had any revelations in the last 24 hours. @SAplayer, can you commit @njx's suggested comment?

@marcelgerber
Copy link
Contributor Author

Just added this comment. Hope everything is fine now.

@lkcampbell
Copy link
Contributor

@SAplayer, there is a Travis build fail. Something about pressEnter() not being defined.

@lkcampbell
Copy link
Contributor

It looks like 5cd2043 removed the pressEnter() function and that is breaking your code.

@marcelgerber
Copy link
Contributor Author

@lkcampbell Just fixed the unit tests. Thanks for your hint!

@lkcampbell
Copy link
Contributor

Looks good. Merging.

lkcampbell added a commit that referenced this pull request Jan 30, 2014
@lkcampbell lkcampbell merged commit 9001a87 into adobe:master Jan 30, 2014
@marcelgerber marcelgerber deleted the replace-dollar-ampersand branch January 31, 2014 14:46
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.

4 participants