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

Disable micro auto formatting bindings.json when adding new bindings #3302

Open
Neko-Box-Coder opened this issue May 19, 2024 · 1 comment
Open

Comments

@Neko-Box-Coder
Copy link
Contributor

Neko-Box-Coder commented May 19, 2024

Description of the problem or steps to reproduce

micro keeps auto formatting bindings.json, when there's a new binding needs to be added to the json (either from user or plugin). Resulting it removing all the comments and reordering everything. Making it difficult to keep track of modified keys.

Specifications

Commit hash: 9176508
OS: Linux
Terminal: WezTerm

@Neko-Box-Coder Neko-Box-Coder changed the title Disable micro auto formatting bindings.json Disable micro auto formatting bindings.json when adding new bindings May 19, 2024
@Neko-Box-Coder
Copy link
Contributor Author

So this happens when whatever is trying to bind/unbind a key, whether it is from the user or a plugin.
The same goes for settings. I guess it's alright it is coming from the user (using bind) but not quite so if it is from the plugin.

Having my keybindings/settings formatting and comments get removed completely is quite annoying and discouraging.

I think we should just do a string append ourselves instead. This should be relatively achievable.
So here are the places where the jsons get write to so that I or someone can come back to later:

txt, _ := json.MarshalIndent(parsedSettings, "", " ")
err = ioutil.WriteFile(filename, append(txt, '\n'), 0644)

txt, _ := json.MarshalIndent(settings, "", " ")
err = ioutil.WriteFile(filename, append(txt, '\n'), 0644)

"MouseLeft": tcell.ButtonPrimary,

txt, _ := json.MarshalIndent(parsed, "", " ")
return true, ioutil.WriteFile(filename, append(txt, '\n'), 0644)

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

No branches or pull requests

1 participant