Skip to content

Fix key ordering quickfix breaks YAML#1175

Merged
datho7561 merged 1 commit intoredhat-developer:mainfrom
shin19991207:chang-patch-1171
Feb 10, 2026
Merged

Fix key ordering quickfix breaks YAML#1175
datho7561 merged 1 commit intoredhat-developer:mainfrom
shin19991207:chang-patch-1171

Conversation

@shin19991207
Copy link
Member

What does this PR do?

Fixes key ordering quick fix cases where applying the fix breaks YAML layout or fail to apply.

  1. Reordering now keeps entries properly separated, one key per line.
    Note that the one key per line is a newly added behavior. To make behavior consistent (I think), I made the rewriter to strip leading blank-line from entries so reordered entries stay one-per-line.
    For example, given:

    one:
      child: moo
    two:
      child: moo
    
    three:
      child: moo

    After reordering keys, we now get:

    one:
      child: moo
    three:
      child: moo
    two:
      child: moo
  2. Reordering now works correctly when the map ends at EOF with a trailing newline. Previously, the quick fix could appear but produce no change when click-onto for inputs like (note the blank line at EOF):

    one:
      child: moo
    two:
      child: moo
    three:
      child: moo
        

    Fixes by normalizing newline token handling at map boundaries and applying the replacement over the correct map range so the edit is always effective.

What issues does this PR fix or reference?

Fixes #1171

Is it tested? How?

Automated test + I tested manually.

Signed-off-by: Morgan Chang <shin19991207@gmail.com>
@coveralls
Copy link

coveralls commented Feb 10, 2026

Coverage Status

coverage: 84.633% (+0.002%) from 84.631%
when pulling 42b6a99 on shin19991207:chang-patch-1171
into 9d3b96f on redhat-developer:main.

@shin19991207 shin19991207 marked this pull request as ready for review February 10, 2026 04:13
Copy link
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works well. Thanks, Morgan

@datho7561 datho7561 merged commit 9543805 into redhat-developer:main Feb 10, 2026
4 checks passed
@shin19991207 shin19991207 deleted the chang-patch-1171 branch February 18, 2026 18:45
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.

Key ordering quickfix breaks YAML

3 participants