Completion Custom Actions

SyntaxEditor for WPF Forum

Posted 9 years ago by Phil Devaney - Senior Software Engineer, Serck Controls Ltd
Version: 11.2.0552
Avatar

Hi,

I'm trying to implement a Completion Custom Action as shown in the IntelliPrompt QuickStarts. I can successfully display a dialog, but the example doesn't show how to then insert text based on the dialog selection into the document.

I have tried



IEditorDocument document = session.View.SyntaxEditor.Document; 
TextRange range = session.SnapshotRange.TextRange; 

// Display dialog here with Window.ShowDialog

document.ReplaceText(TextChangeTypes.AutoComplete, range, myNewText);

I had to save the document & range before displaying the dialog, as otherwise session.View was null after ShowDialog returned, and session.SnapshotRange.IsDeleted was true.

This inserts the new text, but if the user typed a few characters to get to the completion item, they are not replaced as they would be if a normal completion item was selected.

What is the recommended way of doing this?

Comments (2)

Answer - Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Phil,

It doesn't look like we currently expose the snapshot range variable that we use to replace the text with.  But I believe it would effectively be similar to if you took the snapshot range you are saving and if you translated it to the current snapshot like:

snapshotRange.TranslateTo(targetSnapshot, TextRangeTrackingModes.ExpandBothEdges);

Let us know if that helps.


Actipro Software Support

Posted 9 years ago by Phil Devaney - Senior Software Engineer, Serck Controls Ltd
Avatar

Yes, that works perfectly, thanks!

The latest build of this product (v21.1.2) was released 21 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.