Skip to content

Commit

Permalink
- Fix Quick Info not working in some cases (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmjordan committed Jan 5, 2025
1 parent 84fcb81 commit 9ec0688
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 0 additions & 1 deletion Codist/Helpers/ServicesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ private ServicesHelper() {
internal SyntaxHighlight.ClassificationTypeExporter ClassificationTypeExporter { get; }

public static TInterface Get<TInterface, VSInterface>() where TInterface : class {
ThreadHelper.ThrowIfNotOnUIThread();
return ServiceProvider.GlobalProvider.GetService(typeof(VSInterface)) as TInterface;
}

Expand Down
2 changes: 0 additions & 2 deletions Codist/Helpers/ThemeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ static ThemeHelper() {

#region Theme events
static KeyValuePair<Guid, string> GetCurrentThemeInfo() {
ThreadHelper.ThrowIfNotOnUIThread();
var i = ServicesHelper.Get<Interop.IVsColorThemeService, Interop.SVsColorThemeService>();
if (i == null) {
"Failed to cast IVsColorThemeService.".Log();
Expand All @@ -79,7 +78,6 @@ static KeyValuePair<Guid, string> GetCurrentThemeInfo() {
// in VS 2022, SVsColorThemeService somehow can't be cast to IVsColorThemeService,
// we have to use dynamic in this case
static KeyValuePair<Guid, string> CompatibleGetThemeInfo() {
ThreadHelper.ThrowIfNotOnUIThread();
dynamic s = ServiceProvider.GlobalProvider.GetService(new Guid("0D915B59-2ED7-472A-9DE8-9161737EA1C5"));
if (s == null) {
return new KeyValuePair<Guid, string>(Guid.Empty, String.Empty);
Expand Down
13 changes: 12 additions & 1 deletion Codist/QuickInfo/QuickInfoFactories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,18 @@ Task<QuickInfoItem> IAsyncQuickInfoSource.GetQuickInfoItemAsync(IAsyncQuickInfoS
protected abstract Task<QuickInfoItem> GetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken);

async Task<QuickInfoItem> InternalGetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken) {
var item = await GetQuickInfoItemAsync(session, cancellationToken).ConfigureAwait(false);
QuickInfoItem item;
await SyncHelper.SwitchToMainThreadAsync(cancellationToken);
try {
item = await GetQuickInfoItemAsync(session, cancellationToken);
}
catch (OperationCanceledException) {
throw;
}
catch (Exception ex) {
Controls.MessageWindow.Error(ex, null, Properties.Resources.T_SuperQuickInfo, this);
return null;
}
if (item != null) {
session.Properties.AddProperty(GetType(), this);
}
Expand Down

0 comments on commit 9ec0688

Please sign in to comment.