-
Notifications
You must be signed in to change notification settings - Fork 214
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
diffmatchpatch: invalid diff output with CRLF line endings #115
Comments
sergi/go-diff#115 prevents us from upgrading go-diff in gopls. Change-Id: I19aa01aa201b894a537480500ea435f2951a3082 Reviewed-on: https://go-review.googlesource.com/c/tools/+/308829 Trust: Rebecca Stambler <[email protected]> Run-TryBot: Rebecca Stambler <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Robert Findley <[email protected]>
We've just discovered (in https://golang.org/issue/45648) that this probably affects code without CRLF line endings as well. We suspect that this is the cause of an uptick of user-reported formatting problems in gopls, starting around December, due to users installing gopls with Thank you @ShoshinNikita for working on a fix. Is there anything we can do to help get that reviewed and released? |
I can confirm that this patch fixes the repro case provided in #115. |
Thanks Rebecca. Rebecca and I will be pairing on reviewing the change itself on Monday. |
What's the status of this? |
I just ran into this too - about an hour of debugging because I thought I was crazy - I would write "the same" strings into a test program and they would be fine, but those from an environment were not. This must not be fixed because I used latest, so for others that need a quick solution what worked for me is to just strip any kind of newline: import strings
// Strip any kind of newline from the string
func Strip(line string) string {
return strings.NewReplacer(
"\r\n", "",
"\r", "",
"\n", "",
"\v", "",
"\f", "",
"\u0085", "",
"\u2028", "",
"\u2029", "",
).Replace(line)
} And basically parse the strings with that before providing to the library here. |
I believe the fix for #89 introduced regressions for files with
\r\n
line endings. This reproduces as of commit db1b095.The following repro program illustrates the issue. It compares two strings, whose only differences are line endings. (This was caught by a
gopls
test in https://golang.org/cl/275439).Before db1b095, the diffs produced are correct. After, they are:
which is clearly invalid.
The text was updated successfully, but these errors were encountered: