Skip to content

Conversation

dandavison
Copy link
Owner

@dandavison dandavison commented Jun 17, 2020

Fixes #179 cc @phillipwood

  • Unless --keep-plus-minus-markers is in effect, drop the first column so that the real code starts in the first column.

  • Highlight addition of trailing whitespace as a whitespace error (i.e. git's blank-at-eol). Style determined by new option --whitespace-error-style which defaults to git's color.diff.whitespace.

  • Highlight removals and additions of empty lines with background color in the first column if these would not otherwise be visible (i.e. if the applicable style lacks a background color). Style determined by new options --minus-empty-line-marker-style and --plus-empty-line-marker-style.

  • Additions of empty lines at end-of-file are not currently highlighted as whitespace errors, but rather as normal addition-of-empty line. This is contra git's blank-at-eof and is a bug to be addressed in subsequent work.

See git documentation: https://git-scm.com/docs/git-config#Documentation/git-config.txt-corewhitespace

@dandavison dandavison merged commit 9bd9398 into master Jun 17, 2020
@dandavison dandavison deleted the whitespace branch June 17, 2020 21:15
"{}{}",
ANSI_CSI_CLEAR_TO_BOL, ANSI_CSI_CURSOR_BACK_1
))
.to_string(),
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phillipwood I've rebased over the commit on which you commented earlier but the call to ansi_term_style.paint() here wraps \033[1K\033[1D with a prefix which sets the background color and a SGR RESET suffix. Therefore I believe the end result is to emit the pattern of ANSI sequences that you suggested (modulo the details of the background color):

'\033[41m\033[1K\033[1D\033[m\n'

But do let me know if something doesn't look right!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that explains the reset. However I don't think you need ANSI_CSI_CURSOR_BACK_1 though. Looking back at my comments on the issue I must have copied and pasted the wrong line from where I had been playing around in the terminal. It should have been <set background color><ANSI_CLEAR_TO_BOL><ANSI_SGR_RESET><\n> The ANSI_CSI_CUROR_BACK_1 was left over from something else. Sorry for the confusion

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, thanks for that. I have removed the ANSI_CSI_CURSOR_BACK_1.

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.

🚀 empty line handling and getting rid of the space leftover from -/+

2 participants