fix: find-in-text returning a string instead of a zip-loc #89
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Find in Text Selector Return Value
This pull request aims to fix #83, caused due to the
find-in-text
selectorreturning a string rather than a
zip-loc
as expected. I have also addeda test assertion which checks for the expected functionality.
Problem Description
When using the
find-in-text
selector in the last position of achild
selector no result will be found. Expected behavior is restored when you
wrap
find-in-text
with theand
selector. Here is an example of theproblem:
Solution
The current version of
find-in-text
is supposed to return a function that takesa zip-loc and returns a zip-loc if the node contains a text block matching a
provided regular expression. The current body of the function is as follows (minor
readability changes):
The issue is in the return value of the returned function. Running
(some #(re-find re %) ...)
will return the first string matching the regexrather than the zip-loc. For example:
The solution was quite simple: instead of returning the result of
(some ...)
wecheck whether the result returned anything and if it did we then can return the
provided zip-loc. The result is as follows: