locked
Editor Extension: Append to the ITextBuffer of an ITextView RRS feed

  • Question

  • I am writing an editor extension for VS2010 that takes the text in an IWpfTextView, formats the text and updates the IWpfTextView by performing an ITextEdit on the ITextBuffer of the IWpfTextView. However formatting this text may introduce new lines that need to be appended to the underlying ITextBuffer. I run into a situation where I need to grow or append to the ITextBuffer beyond the size of the current buffer.

    How do I go about accomplishing this? ITextEdit.Insert() does not work if the new data goes beyond the length of the current buffer under edit.


    Tuesday, July 19, 2011 8:15 PM

Answers

  • I knew as soon as I posted this I would find the solution. :)

    ITextEdit.Insert() will append to the buffer, however ITextEdit.Apply() must be called after the insert operation, and a new ITextEdit object must be used for the next insert.

    • Marked as answer by Aaron DeMarre Tuesday, July 19, 2011 9:17 PM
    Tuesday, July 19, 2011 9:17 PM

All replies

  • I knew as soon as I posted this I would find the solution. :)

    ITextEdit.Insert() will append to the buffer, however ITextEdit.Apply() must be called after the insert operation, and a new ITextEdit object must be used for the next insert.

    • Marked as answer by Aaron DeMarre Tuesday, July 19, 2011 9:17 PM
    Tuesday, July 19, 2011 9:17 PM
  • HI Aaron

    We are glad to know you have find a solution for this issue.

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, July 20, 2011 1:39 AM