Skip to content

Conversation

@datho7561
Copy link
Contributor

@datho7561 datho7561 commented Oct 1, 2025

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?

  • Unit tests

@coveralls
Copy link

coveralls commented Oct 1, 2025

Coverage Status

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

@datho7561 datho7561 force-pushed the 1119-convert-inline-block-strings branch from 64a73c4 to 6269b2d Compare October 2, 2025 21:07
@datho7561 datho7561 force-pushed the 1119-convert-inline-block-strings branch 8 times, most recently from 479ad4c to d669f4a Compare October 6, 2025 13:59
@datho7561 datho7561 changed the title [WIP] Refactoring to change strings into block scalars Refactoring to change strings into block strings Oct 6, 2025
@datho7561 datho7561 marked this pull request as ready for review October 6, 2025 14:11
@datho7561
Copy link
Contributor Author

@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.

@fbricon fbricon force-pushed the 1119-convert-inline-block-strings branch from d669f4a to f2fb641 Compare December 2, 2025 14:17
@fbricon
Copy link
Contributor

fbricon commented Dec 2, 2025

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

Screenshot 2025-12-02 at 16 35 40

Adds two new refactoring actions to turn quoted strings into block
strings.

eg. if you have the following

```yaml
root: "value1\value2"
```

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

```yaml
root: >-
  value1

  value2
```

or

```yaml
root: |-
  value1
  value2
```

Fixes redhat-developer#1119

Signed-off-by: David Thompson <[email protected]>
@datho7561 datho7561 force-pushed the 1119-convert-inline-block-strings branch from f2fb641 to 5a8c344 Compare December 2, 2025 17:46
@datho7561
Copy link
Contributor Author

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.

@nyarly
Copy link

nyarly commented Dec 2, 2025

@datho7561 Let me see about getting this set up

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

Successfully merging this pull request may close these issues.

Code action: convert inline strings to block (and vice versa)

4 participants