MobiFlight-Connector icon indicating copy to clipboard operation
MobiFlight-Connector copied to clipboard

Fix substring modifier implementation

Open DocMoebiuz opened this issue 5 months ago • 5 comments

fixes #1558

This PR corrects the behavior of substring method. A substring has a Start, and has an End value. The old behavior: End value was not included. The substring "starts" at Start and "ends before" End. The new behavior: End value is included. The substring "starts" at Start and "ends on" End.

  • [x] Substring Start and End mark the characters that will be included with the result
  • [x] Add unit tests

[!NOTE]
this PR also makes sure that the ConnectorValue is properly cloned and used as the result.

DocMoebiuz avatar Jan 09 '24 23:01 DocMoebiuz

Build for this pull request: MobiFlightConnector.zip

github-actions[bot] avatar Jan 09 '24 23:01 github-actions[bot]

What happens to people who have existing modifiers? Do they get auto-migrated to match this new behaviour? Or does everyone have to go and manually clean them up?

neilenns avatar Jan 10 '24 23:01 neilenns

i know. it's not ideal. but i have no good idea to tell whether it's an old config or not.

DocMoebiuz avatar Jan 11 '24 00:01 DocMoebiuz

i know. it's not ideal. but i have no good idea to tell whether it's an old config or not.

All we really need to know is if this specific modifier is old or new. You can add a specific property to just the modifier object to identify that, something like endson=true. If it's missing then you know it's the old style and can auto-update it so it doesn't break the config, and then mark the file as dirty. On save, add the endson=true (or whatever flag name/value you want).

We had a LOT of problems in discord with the change to reverse digits. We should try and find a way to avoid the same thing happening again with this change :)

neilenns avatar Jan 11 '24 01:01 neilenns

I totally agree.

I don't know how many are using this. It was only for FSUIPC string type in the past.

I thought of an extra attribute too and I guess that's the easiest option.

I will add it.

DocMoebiuz avatar Jan 11 '24 06:01 DocMoebiuz