protected async Task <int> GetXamlIndentAsync(IAsyncServiceProvider serviceProvider) { try { var xamlLanguageGuid = new Guid("CD53C9A1-6BC2-412B-BE36-CC715ED8DD41"); var languagePreferences = new LANGPREFERENCES3[1]; languagePreferences[0].guidLang = xamlLanguageGuid; if (await serviceProvider.GetServiceAsync(typeof(SVsTextManager)) is IVsTextManager4 textManager) { textManager.GetUserPreferences4(pViewPrefs: null, pLangPrefs: languagePreferences, pColorPrefs: null); return((int)languagePreferences[0].uIndentSize); } else { RapidXamlPackage.Logger?.RecordError("Failed to get IVsTextManager4 in BaseCommand.GetXamlIndentAsync"); } } catch (Exception exc) { this.Logger.RecordException(exc); } var indent = new Microsoft.VisualStudio.Text.Editor.IndentSize(); return(indent.Default); }
public async Task <int> GetXamlIndentAsync() { try { var xamlLanguageGuid = new Guid("CD53C9A1-6BC2-412B-BE36-CC715ED8DD41"); var languagePreferences = new LANGPREFERENCES3[1]; languagePreferences[0].guidLang = xamlLanguageGuid; var textManager = await this.serviceProvider.GetServiceAsync(typeof(SVsTextManager)) as IVsTextManager4; textManager.GetUserPreferences4(pViewPrefs: null, pLangPrefs: languagePreferences, pColorPrefs: null); return((int)languagePreferences[0].uIndentSize); } catch (Exception exc) { this.logger.RecordException(exc); var indent = new Microsoft.VisualStudio.Text.Editor.IndentSize(); return(indent.Default); } }