Fix OffsetString regex to allow minus sign #18
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.
Issue
Negative values are allowed for the Run Starts At time in the component settings. However, when that value gets formatted and saved into the layout XML, the dash character that a user types with their keyboard is converted into a minus character. When reloading the layout after save, the offset time is set to 0.0 instead of the saved negative value.
Implementation
The current regex allows a dash character but not a minus character, though the TimeFormatter converts the dash into a minus. Updated the regex pattern to use the MINUS and DASH constants defined in LiveSplit to allow both characters in an offset string.
Testing
I built and tested this component myself and verified it works as intended. Entering a negative offset value from my keyboard, which inputs a dash, is saved as expected and loads correctly when the layout is loaded. The video also starts at the correct offset. Also, I manually edited the layout xml to test both minus and dash characters in the offset string are loaded correctly and the video starts at the correct offset in both cases.