Code action: convert inline strings to block (and vice versa)
Is your enhancement related to a problem? Please describe.
Our deployments (uncontrollably) convert block strings to long inline strings. When editing the resulting files in the live server, it would be great to be able to reliably convert them back to a block string.
Wrapping long lines to folded scalars would be welcome as well.
Describe the solution you would like
Given
field: "<1000 word novel>"
If the cursor is in the string, invoking code actions should present two options:
- convert to block scalar
- convert to flow scalar
Because I assume that sometimes the opposite would be desirable:
field: |
<100 lines of prose>
If the cursor is in the string, code actions should include:
- convert to inline scalar
Describe alternatives you have considered
A series of search and replace? Very carefully editing the string without changing it.
This sounds like it would be really helpful, so I'm going to take a look into it.
I have a proof of concept locally that introduces a new diagnostic when an inline string is "too long", then a new quick fix to turn it into a block string. Ideally, we should use a refactoring that's not attached to an error, since a lot error markers can clutter up the UI.
I'm guessing it will be complex to implement, since there's likely many edge cases, and we need to make sure that the value of the text doesn't change. We'll need a new setting too, to specify after how many characters a line should be split.