-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
[fix] Logic error with quotes order #12
Conversation
This comment has been minimized.
This comment has been minimized.
As you can see, the tests I wrote in #11 are now passing (that's also the reason I also included them in this PR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some suggestions, which should be committed before merging...
This comment has been minimized.
This comment has been minimized.
Hi! Thanks! The template includes I like narrowing the problem down as much as possible, which results in a test, and then finding the smallest possible solution, which often impacts that test again. |
released in |
Initial checklist
Description of changes
In this line there is a small logic error, which went unnoticed because there are currently no tests for setting either
smart
orstraight
.Detailed context:
Let's say these are the current vars:
And now look at this line:
We take the length of the stack, which is 1, add 1 to it, which makes 2 and module (
%
) it with the length of the markers, which is 3, in order to make sure, that we don't get any out of range exception.We expect that the
expected
variable is set to the first item in markers, namely'“”'
because this is the very first quote in the paragraph, as you can see: The stack only has the one item, no other quotes have been opened.However, the item with index 2 is the third item, which leads the plugin to say, that the first quote is wrong, it should be the third quote...
Basically, we are ALWAYS 2 indecies ahead of the actual marker we want to be in the var
expected
.This went unnoticed until now, because all tests only ever have max 2 entries in the markers array, which by coincidence doesn't affect the output, because the module
%
resets it to 0, soexpected
gets set to the right item / right index.In order to fix this behaviour, we have to subtract 1 from the stack length, so we are exactly at the index we want to be, like this:
If you have any further questions explaining the issue, please let me know!
smart
(orstraight
) with more than 2 entries, the order is evaluated wrong #11