atom / git-diff

Diff markers in Atom's gutter
MIT License
102 stars 41 forks source link

Position decoration at top of line number when the first line is deleted #146

Closed nathansobo closed 6 years ago

nathansobo commented 6 years ago

Description of the Change

This PR adds special handling for the first line of a file being deleted. Currently, the git-line-removed class always adds decoration to the bottom of the line number. This works well for everything except when the first line is deleted. In that case, we attempt to decorate row -1, which gets clipped to 0. Then the decorations make it look like we've deleted the second line instead of the first. Now if we need to decorate row -1, we instead add git-previous-line-removed class, which duplicates the existing style except for the positioning of the decoration.

Benefits

Correctly indicates when the first line has been deleted.

Alternate Designs

We could have changed the git-line-removed styling to always apply to always render the decoration at the top and apply the decoration to the next line instead. That was a bigger change and seems like it could have issues at the end of the file instead.

Possible Drawbacks

The duplicated style could maybe be done more elegantly with LESS. @simurai I'll defer to you on that on.

Applicable Issues

Closes #128

simurai commented 6 years ago

The duplicated style could maybe be done more elegantly with LESS. @simurai I'll defer to you on that on.

Otherwise this looks good. 👍

nathansobo commented 6 years ago

Thanks for your help @simurai.