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

Fix bug causing increment/decrement issues for some number formats #4221

Merged
merged 1 commit into from
Oct 27, 2019

Conversation

jkillian
Copy link
Contributor

@jkillian jkillian commented Oct 27, 2019

What this PR does / why we need it:
When incrementing or decrementing a number, the NumericString.parse class is used to parse strings in to numbers of various formats. However, it used global (stateful) regexes to do this, which meant that funky things could happen after the first call to the method. This PR fixes the issue by simply removing the g flag from some regexes.

This fixes issues, for example, where pressing <C-a> on certain numbers more than once lead to numeric prefixes getting stripped or other odd behavior.

Which issue(s) this PR fixes
Fixes #3545

Special notes for your reviewer:
@Chillee added the g flag in #1721. I think the rest of the logic in that PR still works correctly without the g flags, but feel free to take a look and verify that this change is safe.

@jkillian jkillian changed the title Fix numeric string parse bug caused by stateful regexes Fix bug causing increment/decrement issues for some number formats Oct 27, 2019
Copy link
Member

@J-Fields J-Fields left a comment

Choose a reason for hiding this comment

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

Thanks!

@J-Fields J-Fields merged commit 854a013 into VSCodeVim:master Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected <c-a> and <c-x> behavior with leading zeros
2 participants