コード例 #1
0
        /// <summary>
        /// Called on buffer save
        /// </summary>
        private void FixBufferOnSave(ITextBuffer buffer, int tabSize, string filePath)
        {
            if (!AlwaysAlignedConfigurationService.Instance.GetConfiguration().ConvertOnLoadSave)
            {
                return;
            }

            using (StreamWriter streamWriter = new StreamWriter(filePath))
            {
                string text          = buffer.CurrentSnapshot.GetText();
                string convertedText = ElasticTabstopsConverter.ToSpaces(text, tabSize);
                streamWriter.Write(convertedText);
            }
        }
コード例 #2
0
        private void _btnAlignSpaces_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.ToSpaces(text, doc.TabSize);

            doc.ReplaceText(text, convertedText);
        }