Skip to content

Fix inserting to the end of a range #714

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jpmelos
Copy link

@jpmelos jpmelos commented May 28, 2025

When you are formatting with a range, and the formatter tries to insert at the end of the range, conform.nvim will fail to insert because it will consider the insert to be happening "outside of the range". But if it's an insert operation that starts immediately after the range, it should be considered still part of the range, since that's basically "appending" to the range, making it longer.

This happens a lot with Markdown formatters, for example. Markdown formatters will reorganize reference links alphabetically, meaning they can change the order of links and remove a link from the start of the link section and insert it at the end of the link section, basically "appending" the link at the end.

First, I add a failing test. Then, I add the code that fixes the test.


I figure this PR description is not super intuitive, so I recorded a video showing the bug, it might be easier to grok it.

conform-nvim-bug.mp4

@github-actions github-actions bot requested a review from stevearc May 28, 2025 03:54
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.

1 participant