/* void TextCut (object sender, ReplaceEventArgs e) * { * if (!string.IsNullOrEmpty (e.Value) || e.Count == 0) * return; * RunFormatterAt (e.Offset); * }*/ void RunFormatterAt(int offset) { if (PropertyService.Get("OnTheFlyFormatting", false) && textEditorData != null && Document != null) { // textEditorData.Document.TextReplaced -= TextCut; ProjectDom dom = Document.Dom; DocumentLocation loc = textEditorData.Document.OffsetToLocation(offset); DomLocation location = new DomLocation(loc.Line, loc.Column); CSharpFormatter.Format(textEditorData, dom, Document.CompilationUnit, location); // textEditorData.Document.TextReplaced += TextCut; } }
void RunFormatter() { if (PropertyService.Get("OnTheFlyFormatting", false) && textEditorData != null) { textEditorData.Paste -= TextEditorDataPaste; // textEditorData.Document.TextReplaced -= TextCut; ProjectDom dom = ProjectDomService.GetProjectDom(Document.Project); if (dom == null) { dom = ProjectDomService.GetFileDom(Document.FileName); } DomLocation location = new DomLocation(textEditorData.Caret.Location.Line, textEditorData.Caret.Location.Column); CSharpFormatter.Format(textEditorData, dom, Document.CompilationUnit, location); // OnTheFlyFormatter.Format (textEditorData, dom, location); // textEditorData.Document.TextReplaced += TextCut; textEditorData.Paste += TextEditorDataPaste; } }