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

Add option to keep quotes #200

Open
Joris29 opened this issue Mar 19, 2024 · 9 comments
Open

Add option to keep quotes #200

Joris29 opened this issue Mar 19, 2024 · 9 comments

Comments

@Joris29
Copy link

Joris29 commented Mar 19, 2024

Could you add an option to just keep quotes as they are when sorting.

Example.
parent_key:
'Pkey2 with space':
k1: v1
k2: 'v2'
'Pkey1 with space':
k1: 'v1'
k2: v2

Would become:
parent_key:
Pkey1 with space:
k1: v1
k2: v2
Pkey2 with space:
k1: v1
k2: v2

What it should be if original quotes are ignored:
parent_key:
'Pkey1 with space':
k1: v1
k2: 'v2'
'Pkey2 with space':
k1: 'v1'
k2: v2

@Joris29
Copy link
Author

Joris29 commented May 30, 2024

@pascalre ?

@paulcalabro
Copy link

Yeah, I agree this is my only annoyance. This breaks my Ansible playbooks since some values need to be quoted, for example when you have a leading "{{".

@Joris29
Copy link
Author

Joris29 commented Jul 19, 2024

@pascalre Is this project dead because you don't seem to react to issues?

@pascalre
Copy link
Owner

Hello @Joris29, this project is not dead. But my time is limited. Feel free to contribute with a PR.

@Joris29
Copy link
Author

Joris29 commented Jul 19, 2024

@pascalre Alright understandable I will try to do an attempt to create a PR for it but i have no knowledge of typescript but I guess I can learn it pretty fast

@Joris29
Copy link
Author

Joris29 commented Jul 19, 2024

This is a reoccurrence of #142 which is partially resolved it's strange behaviour with quoting.

Using just single quotes or double quotes will change to nothing.
Using double quotes inside single quotes like this ' "this is a text" ' will remain as it should.
Using single quotes inside double quotes like this " 'this is a text' " will return three single quotes on each side

Very strange quoting behaviour but i will try to fix it

@Joris29
Copy link
Author

Joris29 commented Jul 20, 2024

After doing some further research there is also another vscode extension for yaml validation which support sorting https://github.com/redhat-developer/yaml-language-server

@paulcalabro If you don't use the custom sorts it might be better to use that one for now. As the code is quite complex for me and it might take a while to have a working solution.

@Joris29
Copy link
Author

Joris29 commented Jul 21, 2024

Seems like a lot of refactoring because the used library doesn't support it: nodeca/js-yaml#711 (comment)

@paulcalabro
Copy link

Thanks @Joris29 !

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

3 participants