Skip to content

upcoming problem with bitflags and key_list ron reading #1929

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

Closed
pm100 opened this issue Oct 19, 2023 · 6 comments
Closed

upcoming problem with bitflags and key_list ron reading #1929

pm100 opened this issue Oct 19, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@pm100
Copy link
Contributor

pm100 commented Oct 19, 2023

While working on the replacement of textinput with tui-textarea I found a problem that is coming down the pipe

when bitflags changed from v1 to v2 they changed their serialization format - see https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md#200-rc2

The current ron files for key mapping use the v1 format - of course

crossterm 0.27 pulls in bitflags v2. This now means that gitui can no longer read its key config files, plus there are two tests that fail.

I upgraded crossterm because tui-textarea asks for 0.27, and anyway I assume gitui would eventually upgrade anyway since its a core dependency

I am not sure if there is a good solution (I dont know serde well enough but have done some reading)

There is a crate that allows reading the old format, but it requires changes to the bitflags definition. The bitflags in key_list ron are defined in crossterm not gitui (KeyModifiers) and it seems like an odd change to ask crossterm to make.

The only other alternatives would be

  • a breaking change
  • code that reads the file before handing it over to serde, changes it on the fly to the new format, then passes an in memory version to serde
  • any other idea?

I dont know if gitui can specify a custom deserializer for the KeyModifiers type

@pm100 pm100 added the bug Something isn't working label Oct 19, 2023
@pm100
Copy link
Contributor Author

pm100 commented Oct 19, 2023

@extrawurst note that the new format is much much nicer

 `tab_toggle_reverse:(code:BackTab,modifiers:"SHIFT"),`

@extrawurst
Copy link
Collaborator

yeah see cargo-update branch

@extrawurst
Copy link
Collaborator

related to #1781

@pm100
Copy link
Contributor Author

pm100 commented Oct 19, 2023

so the plan is the 'breaking change' one?

I will comment out the 2 tests for now

@extrawurst
Copy link
Collaborator

Sure I don’t care to break the format pre 1.0

@joshka
Copy link

joshka commented Nov 23, 2023

any other idea?

For backwards compatibility would it work to map to an enum that has two variants, V1 and V2 with a custom serializer for V1 and a serializer for V2 that defers to the V2 format? Similar to the solution mentioned in https://serde.rs/data-model.html#mapping-into-the-data-model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants