Skip to content
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

diff kitten: CRLF is shown as <d> #638

Closed
maximbaz opened this issue Jun 14, 2018 · 3 comments
Closed

diff kitten: CRLF is shown as <d> #638

maximbaz opened this issue Jun 14, 2018 · 3 comments

Comments

@maximbaz
Copy link
Contributor

Create two files with Windows line endings (i.e. :set ff=dos in vim), then run diff kitten on them. See how <d> is present in the end of every line:

image

It probably makes sense to highlight the difference in line ending if they differ (but not with <d>, maybe with and ), but if they are identical, no symbols should be shown in the diff.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Jun 15, 2018

The diff kitten escapes all control codes in the text it is diffing (except for tab and newline), this is for security purposes, otherwise control codes can be used to hide text from the diff, as they are interpreted by the terminal.

As for showing/hiding them only if they are different, that is not, in general possible. Look at your picture above, the two differences have no direct correspondence, so there is no way to know whether to display them on those lines or not.

The question is what to do with them. Currently all escape codes are replaced by <hex code of the escape code>. CR is 0xd which is why it becomes <d>. Using the unicode symbols doesn't really work, because at typical font sizes, they cannot be read anyway.

The simplest solution is to simply map \r\n to \n But that of course means that viewing the diff when you change line endings will not be very useful.

@kovidgoyal
Copy link
Owner

And just to see what other diff tools do about this:

  1. git diff -- shows \r as ^M
  2. diff -- hides the \r completely

@kovidgoyal
Copy link
Owner

I think I like the git approach best, which is kitty's current approach as well, except that instead of <d> we can use ⏎ for the special case of CRLF

metayan pushed a commit to metayan/kitty that referenced this issue Jun 20, 2018
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

No branches or pull requests

2 participants