spring-projects / spring-projects/spring-tools

No way to insert into YAML without matching indent of previous line

Open
#1,750 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

for: eclipse theme: property-editing-support type: bug
Dominant language
Java
Stars
983
Forks
240
Avg merge
7d 1h
Merged PRs (30d)
7

Description

Describe the bug
Inserting/pasting at the end of a YAML document nests/indents the YAML in an unwated way.

In previous versions of Eclipse STS (3.9 and before), I could cut/copy a section of YAML from one document to the other and it would keep the indentation, but in this version it always appears to match the indentation of last non-empty line preceding the target line for paste. This is not at all helpful, because I would never want to nest my properties farther down than they were in the source document, and it means I always need to adjust the indent after pasting, or else insert a dummy character at the desired indent level before pasting (that I then delete after pasting).

It's possible this should be submitted to another repository, but I don't understand Eclipse well enough to know what piece is causing the issue. If it is actually caused by a switch from one component to another, it might be a feature request vs. a bug, but I don't know if it is or not. At a minimum it would be great to have an option to disable this behavior, even though I don't understand why it would ever be desirable.

To Reproduce
Open an application.yml file in a Spring project using STS for Eclipse 5.0.0.RELEASE (also attempted in 4.30), and populate it with two YAML documents - a sample is below.

Try moving top-level properties/section (e.g., logging in the sample) from one document to the bottom of the other document. When pasted, you will see that the properties are now nested beneath the last property in the target document (in the sample, logging becomes nested beneath spring.activemq.pool).

Sample

spring:
  debug: false
  activemq:
    pool:
      idle-timeout: 2000

---
my-property: hello
logging:
  level:
    root: warn

What I've tried
I've tried making several changes to settings - applying and restarting STS between each.

  • Uncheck all language servers in "Language Servers"
  • Uncheck "YAML (Wild Web Developer)" -> "Format" -> "Enable/disable default YAML formatter"
  • Uncheck "Java" -> "Editor" -> "Typing" -> "When pasting" -> "Adjust indentation"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the paste behavior in an application.yml file using STS for Eclipse 5.0.0.RELEASE or 4.30. Check the Language Servers settings, YAML (Wild Web Developer) formatting options, and Java Editor typing indentation setting to identify which component adjusts pasted YAML. Done means top-level YAML pasted at the document end keeps its source indentation or has a documented way to disable the adjustment.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, yaml
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.