public static LANGPREFERENCES3[] GetNodejsLanguagePreferencesFromTypeScript(IVsTextManager4 textMgr) { var langPrefs = new LANGPREFERENCES3[1]; langPrefs[0].guidLang = Guids.TypeScriptLanguageInfo; ErrorHandler.ThrowOnFailure(textMgr.GetUserPreferences4(null, langPrefs, null)); langPrefs[0].guidLang = typeof(NodejsLanguageInfo).GUID; textMgr.SetUserPreferences4(null, langPrefs, null); return(langPrefs); }
private void SetUserPreferencesMaybeAsync(LANGPREFERENCES3[] languagePreferences) { if (IsForeground()) { Marshal.ThrowExceptionForHR(_textManager.SetUserPreferences4(pViewPrefs: null, pLangPrefs: languagePreferences, pColorPrefs: null)); } else { Task.Factory.StartNew(() => this.SetUserPreferencesMaybeAsync(languagePreferences), CancellationToken.None, TaskCreationOptions.None, ForegroundThreadAffinitizedObject.CurrentForegroundThreadData.TaskScheduler); } }
private async Task SetUserPreferencesMaybeAsync(LANGPREFERENCES3[] languagePreferences) { await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(); Marshal.ThrowExceptionForHR( _textManager.SetUserPreferences4( pViewPrefs: null, pLangPrefs: languagePreferences, pColorPrefs: null ) ); }
private void SetLangPrefs(LANGPREFERENCES3 newPreferences) { IVsTextManager4 textManager = VsAppShell.Current.GlobalServices.GetService <IVsTextManager4>(typeof(SVsTextManager)); Debug.Assert(textManager != null); if (textManager != null) { // Set the language preferences, like "is intellisense turned on?" LANGPREFERENCES3[] langPrefs = { newPreferences }; textManager.SetUserPreferences4(null, langPrefs, null); } }
private void SetUserPreferences() { var langPrefs = new LANGPREFERENCES3[1]; langPrefs[0] = _languageSetting; if (IsForeground()) { Marshal.ThrowExceptionForHR(_textManager.SetUserPreferences4(pViewPrefs: null, pLangPrefs: langPrefs, pColorPrefs: null)); } else { Task.Factory.StartNew(this.SetUserPreferences, CancellationToken.None, TaskCreationOptions.None, ForegroundThreadAffinitizedObject.CurrentForegroundThreadData.TaskScheduler); } }
public static LANGPREFERENCES3[] GetNodejsLanguagePreferencesFromTypeScript(IVsTextManager4 textMgr) { var langPrefs = new LANGPREFERENCES3[1]; langPrefs[0].guidLang = Guids.TypeScriptLanguageInfo; int hr = textMgr.GetUserPreferences4(null, langPrefs, null); if (ErrorHandler.Failed(hr)) { MessageBox.Show(Project.SR.GetString(Project.SR.CouldNotGetTypeScriptLanguagePreferences), Project.SR.ProductName); ErrorHandler.ThrowOnFailure(hr); } langPrefs[0].guidLang = typeof(NodejsLanguageInfo).GUID; textMgr.SetUserPreferences4(null, langPrefs, null); return(langPrefs); }
private void SetUserPreferences() { var langPrefs = new LANGPREFERENCES3[1]; langPrefs[0] = _languageSetting; if (IsForeground()) { Marshal.ThrowExceptionForHR(_textManager.SetUserPreferences4(pViewPrefs: null, pLangPrefs: langPrefs, pColorPrefs: null)); } else { TaskFactory factory = new TaskFactory(ForegroundThreadAffinitizedObject.ForegroundTaskScheduler); factory.StartNew(this.SetUserPreferences); } }
public int OnUserPreferencesChanged4(VIEWPREFERENCES3[] pViewPrefs, LANGPREFERENCES3[] pLangPrefs, FONTCOLORPREFERENCES2[] pColorPrefs) { IVsTextManager4 textMgr = (IVsTextManager4)NodejsPackage.Instance.GetService(typeof(SVsTextManager)); if (pLangPrefs != null && pLangPrefs.Length > 0 && pLangPrefs[0].guidLang == _preferences.guidLang) { _preferences.IndentStyle = pLangPrefs[0].IndentStyle; _preferences.fAutoListMembers = pLangPrefs[0].fAutoListMembers; _preferences.fAutoListParams = pLangPrefs[0].fAutoListParams; _preferences.fHideAdvancedAutoListMembers = pLangPrefs[0].fHideAdvancedAutoListMembers; // Synchronize settings back to TS language service pLangPrefs[0].guidLang = Guids.TypeScriptLanguageInfo; textMgr.SetUserPreferences4(null, pLangPrefs, null); } return(VSConstants.S_OK); }
private void SetUserPreferencesMaybeAsync(LANGPREFERENCES3[] languagePreferences) { if (IsForeground()) { Marshal.ThrowExceptionForHR(_textManager.SetUserPreferences4(pViewPrefs: null, pLangPrefs: languagePreferences, pColorPrefs: null)); } else { Task.Factory.StartNew( async() => { await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(); this.SetUserPreferencesMaybeAsync(languagePreferences); }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap(); } }
private void SetLangPrefs(LANGPREFERENCES3 newPreferences) => _textManager.SetUserPreferences4(null, new LANGPREFERENCES3[] { newPreferences }, null);
public static LANGPREFERENCES3[] GetNodejsLanguagePreferencesFromTypeScript(IVsTextManager4 textMgr) { var langPrefs = new LANGPREFERENCES3[1]; langPrefs[0].guidLang = Guids.TypeScriptLanguageInfo; ErrorHandler.ThrowOnFailure(textMgr.GetUserPreferences4(null, langPrefs, null)); langPrefs[0].guidLang = typeof(NodejsLanguageInfo).GUID; textMgr.SetUserPreferences4(null, langPrefs, null); return langPrefs; }
public static LANGPREFERENCES3[] GetNodejsLanguagePreferencesFromTypeScript(IVsTextManager4 textMgr) { var langPrefs = new LANGPREFERENCES3[1]; langPrefs[0].guidLang = Guids.TypeScriptLanguageInfo; int hr = textMgr.GetUserPreferences4(null, langPrefs, null); if (ErrorHandler.Failed(hr)) { MessageBox.Show(Project.SR.GetString(Project.SR.CouldNotGetTypeScriptLanguagePreferences), Project.SR.ProductName); ErrorHandler.ThrowOnFailure(hr); } langPrefs[0].guidLang = typeof(NodejsLanguageInfo).GUID; textMgr.SetUserPreferences4(null, langPrefs, null); return langPrefs; }