Skip to content

Accurate line numbers for diffs #81

Open
@WarningImHack3r

Description

@WarningImHack3r

What problem are you trying to solve?

Line numbers are incremented linearly in a diff snippet, even though the concept of a diff is to remove and add lines.
As such, the line numbers of a diff should be different from those of a regular code snippet.

Describe the solution you’d like

Ideally, the line numbers should be decremented based on deleted lines.
Image
In this example, as line 7 is a deletion, line 8 should also be numbered 7, and the rest would follow this latter.

More broadly, line numbers after one or more deleted lines should be decremented by the number of deletions.

Describe any alternatives you’ve also considered

Using two columns: one for deleted lines and "normal" lines, and another for added lines and "normal" ones.
This works, but it makes the result inconsistent with regular code snippets. The actual start of code lines would be affected in a diff, but not in a regular snippet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions