Auto-Complete Commit configuration

SyntaxEditor for WPF Forum

Posted 8 years ago by Simon Rose
Version: 15.1.0624
Avatar

Hi,

I have a syntax editor and I'm generating and displaying a completion list. Items in this list may have prefix/suffix characters of ", but many don't.

I have display of the items and the filtering/hiding of them working fine.

However, when I commit a choice, I either get prefixsuffix, e.g. "" and the completion text not between.

I really want the editor to notice if the current "token" has the prefix or not and on commit, apply the prefix, text and suffix (as necessary), resulting in the caret being after all this content.

E.g.

user types si_ but the completion item is prefix=", text=si_temp, suffix=", so on completion, "si_temp"<caret>

user types "si_t but the completion item is prefix=", text=si_temp, suffix=", so on completion, "si_temp"<caret>

Basically, I hope you can see what I'm trying to achieve. Essentially, this is a crude intellisense for an Oracle database to auto-complete table names, but where Oracle has all objects in upper-case normally, you can have database objects that have case-sensitive names if enclosed (created) within "".

Is this possible directly through the completion session, list and item setup or can you hint at ways to tweak what is committed to editor and position the caret correctly?

Any help appreciated.

Simon

Comments (5)

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

Hi Simon,

With completion sessions, you specify the TextRange to track and replace.  You also have full control over the pre-text and post-text that a completion item injects in place of that text range.  From what you wrote, it seems like the pre-text would be your full completion (with quotes if you want those inserted) and post-text would be null.  That would have the caret go after the completed text.

You would need to do some quick token scanning right before opening the session so you know the text range with which to initialize it.  You'd want to scan and make sure surrounding quotes, if there, are included. 

With those updates, it should probably be working how you want.


Actipro Software Support

Posted 8 years ago by Simon Rose
Avatar

Hi,

Thanks for this response. Ok, some of that makes sense, so I'll travel down this angle. I'm not completely down with text ranges and scanning yet, but I'll give it a go. :)

Thanks,

Simon

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

Hi Simon,

Check out the "Scanning Text Using a Reader" topic in the documentation as that tells you how to get a reader.  A snapshot reader can iterate through text or tokens, so that's what you'd want to use.


Actipro Software Support

Posted 8 years ago by Simon Rose
Avatar

Ok, a good hint. I'll take a look at that later today.

Thanks,

Simon

Posted 8 years ago by Simon Rose
Avatar

Hi,

I believe I now have this working.

I'm using the CompletionSession Committed event to get the item inserted and my tag information back, then using a reader to move a token or so left and then figuring out if the user has typed one of the prefix characters and depending on if there should be prefix/suffix or not, making selections and inserting/removing the prefix/suffix character as need.

I did try to setup the completion item's prefix as "si_temp", but unfortunately if the user typed "si_, then asked for the completion list and chose si_temp, they ended up with the following state ""si_temp<caret>". Letting the completion handle just the si_temp bit, my code results in "si_temp"<caret>, which is what I need.

Thanks for the guidance. :)

Simon

[Modified 8 years ago]

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.