Posted 13 years ago
by matthias kossiek
Hi, we are using version 2011.1 build 0543.
I want to insert a xml snippet in EditorDocument in the next line under an existing element. Indent layout should be preserved.
What I tried to do:
- Setup the Document:- and then after loading the xml-file call a method to insert the snippet:
This means, I make a CR/LF behind the existing xml element and than insert the new snippet at the new position. (I also tried TextChangeTypes.Replace)
What I expect is:What I get is:
-> Indent layout is lost for the inserted snippet.
How would you insert a code snippet only using the EditorDocument?
I want to insert a xml snippet in EditorDocument in the next line under an existing element. Indent layout should be preserved.
What I tried to do:
- Setup the Document:
EditorDocument doc = new EditorDocument();
doc.Language = new XmlSyntaxLanguage();
doc.LanguageData = new XmlSchemaResolver();
TextChangeOptions options = new TextChangeOptions();
options.OffsetDelta = TextChangeOffsetDelta.SequentialOnly;
ITextChange change = xamlWorkerEditorDocument.CreateTextChange(TextChangeTypes.AutoIndent, options);
change.InsertText(existingXmlElementEndOffset, "\r\n");
change.InsertText(existingXmlElementEndOffset, snippetString));
change.Apply();
What I expect is:
<rootelement>
<existingElement/>
<snippetElement/>
</rootelement>
<rootelement>
<existingElement/>
<snippetElement/>
</rootelement>
How would you insert a code snippet only using the EditorDocument?