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

Feature brainstorm: highlight character position where edit occurred #75

Closed
unphased opened this issue Sep 26, 2013 · 4 comments
Closed

Comments

@unphased
Copy link

I'm somewhat certain that this is possible to do, because Syntastic does it.

In much the same way as the gutter does, but with only text background colors, mark out the positions in the lines where the edits had taken place. For instance, if I add a space into a line the line will become changed and marked with a ! sign, but it would also be super nice if I could see where the edit happened: e.g., a red-background character in the edited line would indicate that the line had content removed from it there, and added characters would be shown in green. It would be nice to be able to attach a number to the red character as well, but that is likely to be difficult.

@mhinz
Copy link
Owner

mhinz commented Sep 26, 2013

So more or less the same as #32. :)

The main problem is, that diff tools say nothing about columns, so it's kind of hard to highlight specific changes on a line.

@mhinz mhinz closed this as completed Sep 26, 2013
@unphased
Copy link
Author

Right you'll want to run a char-diff over the paired up lines (that we already know are the !-marked lines, and this could be a low-effort kind of thing (like the way vimdiff does it, which isn't a true diff). At any rate I'm super happy to find out that apparently something like this is in the works for 2.0!

@mhinz
Copy link
Owner

mhinz commented Sep 26, 2013

You have to realize that Vim (or the plugin) doesn't know about any other files. It doesn't know the files it "diffs against", because it just processes text that some external tool generates. And that text doesn't say anything about where something on the lines has changed.

I yet have to come up with a method that doesn't have grave influence on the performance.

vimdiff knows both files that are getting diffed and can compare them much faster than any plugin, because it uses compiled code.

@unphased
Copy link
Author

Yes so that external tool should at some stage both identify and diff the lines which are corresponding (which show up marked as !) so vim can parse out where to put indicators. I never said this would be very easy though.

One way, which is probably horrible for performance, is to just convert the pair of lines into a pair of files each with one character per line and run diff on that.

I do have a c++ character differ tool I built based on this which would be much speedier. Someday I have to tidy it up and post on github. Problem is, it doesn't have a line-based diff mode, it's a fully character based diff, with a fundamentally different form of output compared to the standard diff output (with @@ chunks, etc).

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