Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 1f3d242

Browse files
committed
Fix MismatchLayout error in locks view
1 parent 9cdc874 commit 1f3d242

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/GitHub.Api/Tasks/ProcessTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,4 +544,4 @@ public SimpleListProcessTask(CancellationToken token, NPath fullPathToExecutable
544544
public override string ProcessName => fullPathToExecutable;
545545
public override string ProcessArguments => arguments;
546546
}
547-
}
547+
}

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/LocksView.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class LocksControl
5151
[NonSerialized] private GitLockEntry rightClickNextRenderEntry;
5252
[NonSerialized] private int controlId;
5353
[NonSerialized] private UnityEngine.Object lastActivatedObject;
54+
[NonSerialized] private Dictionary<string, bool> visibleItems = new Dictionary<string, bool>();
5455

5556
[SerializeField] private Vector2 scroll;
5657
[SerializeField] private List<GitLockEntry> gitLockEntries = new List<GitLockEntry>();
@@ -106,15 +107,19 @@ public bool Render(Rect containingRect, Action<GitLock> singleClick = null,
106107
var endDisplay = scroll.y + containingRect.height;
107108

108109
var rect = new Rect(containingRect.x, containingRect.y, containingRect.width, 0);
109-
110110
for (var index = 0; index < gitLockEntries.Count; index++)
111111
{
112112
var entry = gitLockEntries[index];
113113

114114
var entryRect = new Rect(rect.x, rect.y, rect.width, Styles.LocksEntryHeight);
115115

116-
var shouldRenderEntry = !(entryRect.y > endDisplay || entryRect.yMax < startDisplay);
117-
if (shouldRenderEntry)
116+
if (Event.current.type == EventType.Layout)
117+
{
118+
var shouldRenderEntry = !(entryRect.y > endDisplay || entryRect.yMax < startDisplay);
119+
visibleItems[entry.GitLock.ID] = shouldRenderEntry;
120+
}
121+
122+
if (visibleItems[entry.GitLock.ID])
118123
{
119124
entryRect = RenderEntry(entryRect, entry);
120125
}
@@ -225,6 +230,7 @@ public void Load(List<GitLock> locks, List<GitStatusEntry> gitStatusEntries)
225230
var scrollIndex = (int)(scrollValue / Styles.LocksEntryHeight);
226231

227232
assets.Clear();
233+
visibleItems.Clear();
228234

229235
gitLockEntries = locks.Select(gitLock =>
230236
{
@@ -244,6 +250,7 @@ public void Load(List<GitLock> locks, List<GitStatusEntry> gitStatusEntries)
244250
assets.Add(assetGuid, gitLockEntry);
245251
}
246252

253+
visibleItems.Add(gitLockEntry.GitLock.ID, false);
247254
return gitLockEntry;
248255
}).ToList();
249256

0 commit comments

Comments
 (0)