eclipse-xtext / eclipse-xtext/xtext
RegionDiffFormatter may drop essential changes at the boundary of a change region
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 831
- Forks
- 330
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 12
Description
In our DSLs this surfaced as a regression due to commit 43b7d1df8c597178fc2fe74db0e173f6a0bbae15 (no issue #):
When a formatter requests two preceding newlines for element X (x.prepend[newLines=2]), then inserting a new element X will correctly create a text change "\n" -> "\n\n", but since commit 43b7d1, this change will be dropped, because it is not contained in the modified region. This happens because SequentialRegionDiff#substituteFirst is an IWhitespace ("\n"), not an IHiddenRegion, which implies that the modified region starts at substituteFirst.getEndOffset() and hence does not cover the desired change.
Consequently, the resulting model source will violate the formatter rule.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing RegionDiffFormatter and SequentialRegionDiff#substituteFirst, using the boundary case described for x.prepend[newLines=2] as the reproduction. Check how the modified region is calculated after commit 43b7d1df8c597178fc2fe74db0e173f6a0bbae15; done means the "\n" to "\n\n" change is retained and the formatter rule is no longer violated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100