Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug in Processor class - it unexpectedly strips the final TextEdit in some cases #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Processor {
}

// Yield the remaining text.
if (element.value.lastIndex > startIndex) {
if (element.value.lastIndex >= startIndex) {
val text = element.value.substring(startIndex)
yield(TextElement(text))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,24 @@ internal class ProcessorTest {
),
processor.escapeTextToLiterals(pattern)
)

pattern.elements.clear()
pattern.elements.addAll(
arrayOf(
TextElement("Hi "),
Placeable(expression = VariableReference(Identifier("var"))),
TextElement("!")
)
)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@gueroJeff @RRagnar Thank you! Can you please add an inline comment in the PR, like this:

Suggested change
// The superfluous empty string literal is a bug. See #49.

assertEquals(
Pattern(
TextElement("Hi "),
Placeable(expression = StringLiteral("")),
Copy link
Contributor

Choose a reason for hiding this comment

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

This expression here shouldn't pop up, and indicates a bug. I'm not sure that it's a bug in this patch, though.

Copy link
Author

Choose a reason for hiding this comment

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

yes, it's another issue. I had to post-process a pattern to remove the redundant empty string literals in my app after this escaping.

Copy link
Author

Choose a reason for hiding this comment

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

I've created the issue for this #49

Placeable(expression = VariableReference(Identifier("var"))),
TextElement("!")
),
processor.escapeTextToLiterals(pattern)
)
}
}