Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue with applying edits #75

Merged
merged 1 commit into from
Feb 10, 2017
Merged

Conversation

xiamx
Copy link
Contributor

@xiamx xiamx commented Feb 8, 2017

In this pull request we address the issue raised in #74 and SweetIQ/schemats#37

Basically, in formatter.ts applyEdits function, we apply the edits from the end of the file towards the beginning, under the assumption that ts.formatting.formatDocument always returns an edits array sorted in ascending order of the change start point. In practice, this assumption is not always held true. This is the cause for the bugs mentioned above.

To resolve this, we simply sort the edits array in ascending order of its change start point.

@vvakame vvakame merged commit 8d7dfc2 into vvakame:master Feb 10, 2017
@vvakame
Copy link
Owner

vvakame commented Feb 10, 2017

wow, good catch! thank you for your contributions.

@xiamx xiamx deleted the applyeditfix branch February 10, 2017 17:14
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.

2 participants