-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conflicts: allow missing newlines at end of file
Currently, conflict markers are materialized in a format that cannot be parsed if a conflict appears at the end of the file, and there is a non-empty line which doesn't end with a newline character. To fix this issue, we can add an extra newline to every term of the conflict when this occurs and then ignore the added newlines when parsing the conflict. To ensure unambiguous parsing, we can add a "[noeol]" tag to the start conflict marker (`<<<<<<<`) when this occurs. I think this is a good solution to the problem because it should remain understandable to users even if they aren't familiar with file encodings. Many editors represent newlines at the end of files by showing an empty line at the end of the editor, so it should be intuitive that a term ending with an empty line represents a newline, while a term that doesn't end with an empty line represents the lack of a newline. Also, adding a newline to every term of the hunk is easier than keeping track of which terms have added newlines and which don't, so it makes materialization/parsing easier. For instance, a conflict with terms `["left\n", "base", "base\nright"]` would look like: ``` <<<<<<< Conflict 1 of 1 [noeol] +++++++ Contents of side jj-vcs#1 left %%%%%%% Changes from base to side jj-vcs#2 base +right >>>>>>> ```
- Loading branch information
Showing
3 changed files
with
302 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.