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

Commit ecea5e8

Browse files
authored
Merge branch 'master' into fixes/951-blend-crash
2 parents a3e99d4 + 21c38f1 commit ecea5e8

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/GitHub.App/ViewModels/RepositoryCloneViewModel.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,17 @@ public override void Initialize([AllowNull] ViewWithData data)
125125

126126
IsBusy = true;
127127
repositoryHost.ModelService.GetRepositories(repositories);
128-
repositories.OriginalCompleted.Subscribe(
129-
_ => { }
130-
, ex =>
131-
{
132-
LoadingFailed = true;
133-
IsBusy = false;
134-
log.Error("Error while loading repositories", ex);
135-
},
136-
() => IsBusy = false
128+
repositories.OriginalCompleted
129+
.ObserveOn(RxApp.MainThreadScheduler)
130+
.Subscribe(
131+
_ => { }
132+
, ex =>
133+
{
134+
LoadingFailed = true;
135+
IsBusy = false;
136+
log.Error("Error while loading repositories", ex);
137+
},
138+
() => IsBusy = false
137139
);
138140
repositories.Subscribe();
139141
}

src/GitHub.Exports/Models/DiffUtilities.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ public static DiffLine Match(IEnumerable<DiffChunk> diff, IList<DiffLine> target
9696
{
9797
if (source.Lines[i].Content == target[j].Content)
9898
{
99-
if (++j == target.Count) return source.Lines[i + j - 1];
99+
if (++j == target.Count || i == 0)
100+
{
101+
return source.Lines[i + j - 1];
102+
}
100103
}
101104
else
102105
{

test/GitHub.InlineReviews.UnitTests/Models/DiffUtilitiesTests.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,20 @@ public class TheMatchMethod
173173
{
174174
[Theory]
175175
[InlineData(" 1", " 1", 0)]
176-
[InlineData(" 1\n 2", " 2", 1)]
177-
[InlineData(" 1\n 1", " 1", 1)] // match the later line
176+
[InlineData(" 1. 2", " 2", 1)]
177+
[InlineData(" 1. 1", " 1", 1)] // match the later line
178178
[InlineData("+x", "-x", -1)]
179179
[InlineData("", " x", -1)]
180180
[InlineData(" x", "", -1)]
181+
182+
[InlineData(" 1. 2.", " 2. 1.", 1)] // matched full context
183+
[InlineData(" 1. 2.", " 2. 3.", -1)] // didn't match full context
184+
[InlineData(" 2.", " 2. 1.", 0)] // match if we run out of context lines
181185
public void MatchLine(string lines1, string lines2, int skip /* -1 for no match */)
182186
{
183187
var header = "@@ -1 +1 @@";
188+
lines1 = lines1.Replace(".", "\r\n");
189+
lines2 = lines2.Replace(".", "\r\n");
184190
var chunks1 = DiffUtilities.ParseFragment(header + "\n" + lines1).ToList();
185191
var chunks2 = DiffUtilities.ParseFragment(header + "\n" + lines2).ToList();
186192
var expectLine = (skip != -1) ? chunks1.First().Lines.Skip(skip).First() : null;

0 commit comments

Comments
 (0)