private void _btnAlignTabsElastic_Click() { if (AppInfo.appObject.ActiveDocument == null) { return; } var doc = (TextDocument)AppInfo.appObject.ActiveDocument.Object("TextDocument"); if (doc == null) { return; } string text = doc.StartPoint.CreateEditPoint().GetText(doc.EndPoint); string convertedText = ElasticTabstopsConverter.ToElasticTabstops(text, doc.TabSize); doc.ReplaceText(text, convertedText); }
/// <summary> /// Called on buffer load /// </summary> private static void FixBufferOnLoad(ITextBuffer buffer, int tabSize) { if (!AlwaysAlignedConfigurationService.Instance.GetConfiguration().ConvertOnLoadSave) { return; } string str = buffer.CurrentSnapshot.GetText(); if (str.Contains("\t")) { MiscGui.WriteOutput("Always Aligned is set to convert files from using spaces when loading, but at least one tab was found. The file will be left alone."); } else { string convertedText = ElasticTabstopsConverter.ToElasticTabstops(str, tabSize); ITextEdit tb = buffer.CreateEdit(); tb.Replace(new Span(0, buffer.CurrentSnapshot.Length), convertedText); tb.Apply(); } }