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

[Feature Request] Adding a way to add keys automatically in all layers if added on defsrc #39

Open
jvlara opened this issue Oct 10, 2024 · 2 comments

Comments

@jvlara
Copy link

jvlara commented Oct 10, 2024

Hi, first of all, thank you for this extension; it is really handy!

I have a large configuration file in my kdb file with 7 layers, and now I want to add more keys. However, adding them in the same order across every layer is a bit of a pain.

If the autoformatter could detect when I add something to defsrc and automatically add _ on every defined layer, that would be really useful. The potential issue I see is that this behavior might not be intended if process-unmapped-keys is set to no, which is not my case.

What do you think? Does it make sense?

@rszyma
Copy link
Owner

rszyma commented Oct 10, 2024

Makes sense. I'm can't think of the reason why you say process-unmapped-keys would interfere with this feature, can you explain?

Detailed behavior I would implement:

  • only adding (1 or more) keys to defsrc should trigger adding _ to all deflayers; removing won't (unless all deflayers in a particular position contain _)
  • number of keys in all deflayers must be the same to trigger this

Potential problems:

  • the formatter is currently stateless (doesn't have info about previous state), so adding a new key to the end of defsrc will work without issues, but adding a new key in the middle, the formatter will have no idea it was added to a specific position, only that "there's now 1 more key than all other deflayers)

@jvlara
Copy link
Author

jvlara commented Oct 10, 2024

Thinking about this a second time makes me realize that process-unmapped-keys should not be affected by this. I didn't go into the details of the code, but when formatting, I think it would be possible to scan the file and detect that defsrc has one key that the other does not and where that key is

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

2 participants