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

Commit e5bd24d

Browse files
committed
Wait for tags to initialize before navigating
We need to wait for the inline comment tags to initialize so we can find the next inline comment. There must be a better way of doing this!
1 parent 4eed05d commit e5bd24d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/GitHub.App/Services/PullRequestEditorService.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,28 +235,26 @@ public async Task<IDifferenceViewer> OpenDiff(
235235
FromLine = thread.LineNumber - 1,
236236
};
237237

238-
await RaiseWhenAvailable(Guids.CommandSetString, PkgCmdIDList.NextInlineCommentId, param, 1000);
238+
// HACK: We need to wait here for the inline comment tags to initialize so we can find the next inline comment.
239+
// There must be a better way of doing this.
240+
await Task.Delay(1500);
241+
RaiseWhenAvailable(Guids.CommandSetString, PkgCmdIDList.NextInlineCommentId, param);
239242

240243
return diffViewer;
241244
}
242245

243-
static async Task<bool> RaiseWhenAvailable(string guid, int id, object param, int millisecondsDelay)
246+
static bool RaiseWhenAvailable(string guid, int id, object param)
244247
{
245248
var commands = VisualStudio.Services.Dte.Commands;
246249
var command = commands.Item(guid, id);
247250

248-
if (!command.IsAvailable)
251+
if (command.IsAvailable)
249252
{
250-
await Task.Delay(millisecondsDelay);
253+
commands.Raise(command.Guid, command.ID, ref param, null);
254+
return true;
251255
}
252256

253-
if (!command.IsAvailable)
254-
{
255-
return false;
256-
}
257-
258-
commands.Raise(command.Guid, command.ID, ref param, null);
259-
return true;
257+
return false;
260258
}
261259

262260
public void NavigateToEquivalentPosition(IVsTextView sourceView, IVsTextView targetView)

0 commit comments

Comments
 (0)