yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

Refactoring to change strings into block strings

Open datho7561 opened this issue 3 months ago • 5 comments

What does this PR do?

Adds two refactorings that change inline strings (i.e. ~~unquoted~~, single quoted, double quoted) into block strings. One for folded block string and one for literal block string.

eg. if you have the following

root: "value1\value2"

There are two refactoring actions so that it can be turned into

root: >-
  value1

  value2

or

root: |-
  value1
  value2

What issues does this PR fix or reference?

Fixes #1119

Is it tested? How?

  • [x] Unit tests

datho7561 avatar Oct 01 '25 21:10 datho7561

Coverage Status

coverage: 84.102% (+0.1%) from 83.961% when pulling 5a8c3446f5635752f879c5e730c75c6df6a6b426 on datho7561:1119-convert-inline-block-strings into 67ecad2fca1d5773e4bceb397e386d2533120cb3 on redhat-developer:main.

coveralls avatar Oct 01 '25 21:10 coveralls

@nyarly if you have time, do you mind trying this out to see if it works well for you? I think it's mostly working, but there might be some edge cases I haven't considered.

If you need help getting the project set up, free free to ask about that.

datho7561 avatar Oct 06 '25 14:10 datho7561

You get as many code action pairs as there are new lines in string literals

Screenshot 2025-12-02 at 16 35 40

fbricon avatar Dec 02 '25 15:12 fbricon

You get as many code action pairs as there are new lines in string literals

Should be fixed, I wasn't checking against the cursor position/selection range so I was suggesting all potential string conversions in the document.

datho7561 avatar Dec 02 '25 17:12 datho7561

@datho7561 Let me see about getting this set up

nyarly avatar Dec 02 '25 18:12 nyarly