-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Handle diff3 conflict markers #62391
Conversation
src/EditorFeatures/CSharpTest/ConflictMarkerResolution/ConflictMarkerResolutionTests.cs
Outdated
Show resolved
Hide resolved
oops. missed this is draft. ping me when you would like a review :) In reply to: 1175590449 |
src/Features/Core/Portable/ConflictMarkerResolution/AbstractConflictMarkerCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/ConflictMarkerResolution/AbstractConflictMarkerCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/ConflictMarkerResolution/AbstractConflictMarkerCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
firstMiddleLine = secondMiddleLine; | ||
} | ||
|
||
return success; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: all these blocks end teh same way. so instead, can you break out and then handle the firstMiddleLien = secondMiddleLine
stuff outside the switch? thanks! #Closed
src/Features/Core/Portable/ConflictMarkerResolution/AbstractConflictMarkerCodeFixProvider.cs
Show resolved
Hide resolved
@CyrusNajmabadi I added VB support and some classification tests |
IDE lgtm :) |
@jcouv Oh goodness this has bugged me for a long time. Thanks for fixing it! In reply to: 1178044319 |
|
||
trivia = token.LeadingTrivia[2]; | ||
Assert.True(trivia.Kind() == SyntaxKind.DisabledTextTrivia); | ||
Assert.Equal("disabled text 2\r\n======= \r\nmore disabled text\r\n", trivia.ToFullString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it fine that we don't lex this as disabled text, followed by a conflict marker, followed by more disabled text? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so. That's what we did prior to this PR and I can't think of any benefit to trying to parse the second =======
as a marker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would in fact have been concerned if we did lex this as a marker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you help me understand why that would be a concern? It seems like if we want to represent conflict regions in structured trivia then we would want to indicate which things are markers and which things are "content".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There aren't any diff styles (that I know of) where there are two =======
sections.
@dotnet/roslyn-compiler for review. Thanks |
@dotnet/roslyn-compiler for second review. Thanks |
3 similar comments
@dotnet/roslyn-compiler for second review. Thanks |
@dotnet/roslyn-compiler for second review. Thanks |
@dotnet/roslyn-compiler for second review. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done review pass.
public void TestEqualsConflictMarker3() | ||
{ | ||
// second ======= is part of disabled text | ||
var token = Lex("======= Trailing\r\ndisabled text 2\r\n======= \r\nmore disabled text\r\n>>>>>>> Actually the end").First(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the rest of these tests are using the single-line syntax, but can we use raw strings here for readability? I find it very hard to understand what this is testing. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a main problem with the compiler test codebase is that its git rules transforms the content to have unix vs windows newlines when going between systems. So it's hard to actually test/validate things like this with raw strings since the test input literally changes depending on the system you run it on. You'd need to have the test validation do the same to make up for this.
My preference would be that files are data and for many reasons (consistency, determinism, etc.) the contents are the same no matter what system you are on.
|
||
trivia = token.LeadingTrivia[2]; | ||
Assert.True(trivia.Kind() == SyntaxKind.DisabledTextTrivia); | ||
Assert.Equal("disabled text 2\r\n======= \r\nmore disabled text\r\n", trivia.ToFullString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would in fact have been concerned if we did lex this as a marker.
public void TestPipeConflictMarker5() | ||
{ | ||
// second ||||||| is pat of disabled text | ||
var token = Lex("||||||| Mid\r\ndisabled text 1\r\n||||||| \r\nmore disabled text\r\n======= Trailing\r\ndisabled text 2\r\n>>>>>>> Actually the end").First(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test with =======
first as well? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added TestEqualsConflictMarker4
to test =======
followed by |||||||
* upstream/main: (40 commits) Revert "Generalize RoamingProfileStorageLocation to ClientSettingsStorageLocation (dotnet#62684)" Revert "Update SymReader to the latest version (dotnet#62695)" Apply changes directly to text buffer - take 2 (dotnet#62617) Allow diagnostic tagging to use either push or pull diagnostics Tests test and more tests Fix new rename showing overloads when not applicable (dotnet#62559) Add stronger type safety Add support for resolving contextual error types Pass LineFormatting options into OmniSharpCodeAction options Initial approach to supporting contextual types Update dependencies from https://github.com/dotnet/arcade build 20220715.4 (dotnet#62704) Handle diff3 conflict markers (dotnet#62391) Update SymReader to the latest version (dotnet#62695) Generalize RoamingProfileStorageLocation to ClientSettingsStorageLocation (dotnet#62684) Add IWorkspaceProjectContextFactory F# wappers (dotnet#62646) Use OmniSharp LineFormatting fallback options in more places. Remove dependency on Microsoft.VisualStudio.RemoteControl assembly from Features (dotnet#62655) Add array initialization optimization (dotnet#62392) [main] Update dependencies from dotnet/arcade (dotnet#62597) Keep selection on rename invocation (dotnet#62654) ...
Extends our support for diff markers in source to diff3 format (which adds a '|||||||' conflict marker).
Recent example of diff3: 80bdf24
git config --global merge.conflictstyle diff3