Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit e4afad9

Browse files
committed
Show RightViewOnly when no changes in PR file diff
If LeftView and RightView text are identical, simply show RightViewOnly.
1 parent c0364af commit e4afad9

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/GitHub.App/Services/PullRequestEditorService.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,23 @@ await pullRequestService.ExtractToTempFile(
194194

195195
diffViewer = GetDiffViewer(frame);
196196

197-
if (diffViewer.LeftView.TextBuffer.CurrentSnapshot.GetText() == string.Empty)
197+
var leftText = diffViewer.LeftView.TextBuffer.CurrentSnapshot.GetText();
198+
var rightText = diffViewer.RightView.TextBuffer.CurrentSnapshot.GetText();
199+
if (leftText == string.Empty)
198200
{
199201
// Don't show LeftView when empty.
200202
diffViewer.ViewMode = DifferenceViewMode.RightViewOnly;
201203
}
202-
else if (diffViewer.RightView.TextBuffer.CurrentSnapshot.GetText() == string.Empty)
204+
else if (rightText == string.Empty)
203205
{
204206
// Don't show RightView when empty.
205207
diffViewer.ViewMode = DifferenceViewMode.LeftViewOnly;
206208
}
209+
else if (leftText == rightText)
210+
{
211+
// Don't show LeftView when no changes.
212+
diffViewer.ViewMode = DifferenceViewMode.RightViewOnly;
213+
}
207214

208215
AddBufferTag(diffViewer.LeftView.TextBuffer, session, leftPath, mergeBase, DiffSide.Left);
209216

src/GitHub.VisualStudio/Commands/OpenFileInSolutionCommand.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ public override async Task Execute()
108108
// TODO: add metrics
109109
// await usageTracker.Value.IncrementCounter(x => x.NumberOf???);
110110

111-
var sessionFile = await session.GetFile(relativePath);
112-
if (sessionFile.Diff.Count == 0)
113-
{
114-
statusBar.Value.ShowMessage("No changes in PR file: " + relativePath);
115-
return;
116-
}
117111

118112
var diffViewer = await pullRequestEditorService.Value.OpenDiff(session, relativePath, "HEAD", scrollToFirstDiff: false);
119113
if (diffViewer == null)

0 commit comments

Comments
 (0)