Selection by typing not working in programmically opend CompletionSession

SyntaxEditor for Windows Forms Forum

Posted 4 months ago by Sylko Zschiedrich
Version: 22.1.3
Platform: .NET 4.8
Environment: Windows 11 (64-bit)
Avatar

Hi all!

I have created my own CompletionProvider and CompletionSession for a special dollar notation.This CompletionSession is not just a simple list of items, with the right arrow key you can open a sub completion list and the first list will be closed. This works fine, except the selection by typing in the second/sub-completion list.

Is there any trick to reset the selection functionality for CompletionSessions?

This is how I open the second DollarCompletionSession in the OnViewKeyDown of the DollarCompletionSession

var sNew = new DollarCompletionSession(_view, _session, part);

sNew.Open(_view);

Thanks for any suggestions

Sylko

Comments (4)

Posted 4 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Sylko,

Do you mean that the second completion session's auto-complete range isn't set to what the first session's auto-complete text range was?  If so, this would result in the initial selection not being based on what was typed so far in the first session, as well as the second session not replacing the typed text from the first session when auto-completing.

What you can do is call the sNew.Open overload that also lets you pass a TextRange argument.  Translate the first session's SnapshotRange to the view's current snapshot, and pass that resulting range into the TextRange argument.  That way the second session should be initialized with all the edits made to the first session's auto-complete range.


Actipro Software Support

Posted 4 months ago by Sylko Zschiedrich
Avatar

Thank you for your quick answer.

The issue is not the text that will be replaced/inserted from the second auto-completion list. It's the (pre) selection in the list by typing.

How it works now.

1. User types a $ character in the editor and the first completion list will open.

2. The user can preselect an item by typing e.g. "uid" until the correct CompletionListItem is selected/focused. e.g. UID_Department

3. User can use the right cursor key to (->) to commit this item and the second AutoCompletionList will be open.

4. Now the user is able to navigate in the list with the cursor keys or the mouse but preselection by typing is not working.

I do not know where this preselection with the typed characters is stored from the first completion list.

Thanks

Sylko

Posted 4 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Sylko,

The selection of completion list items from typing should be coming from the text in the TextRange that was used to initialize the completion list session when it opened, and then appended with whatever text is typed after the session is open.  Per the previous reply, if you specify a TextRange for the second session (and it could be a zero-length text range at the caret offset if you want a pure, blank initialization), you have full control over what that initialization range is.  If you use the session Open method overload that doesn't specify a TextRange, it will try and initialize with the text range of the previous/current word.  Therefore if you use that oerload, and you type "foo" in the second session, you might have "UID_Departmentfoo" or something like that as what's trying to match in the second session.  I'd recommend trying to pass a zero-length TextRange at the caret offset when you open the second session and see if it helps.  If not, we'll need more detail or ideally a new simple sample project that shows it happening so we can debug with that.  Thanks!


Actipro Software Support

Answer - Posted 4 months ago by Sylko Zschiedrich
Avatar

Thanks again for your help.

I found the solution.

MatchOptions = CompletionMatchOptions.TargetsDisplayText;

The AutoCompletePreText in the second CompletionSession contains parts of the first CompeletionSession and did not match to the items Text property.

Regards
Sylko

The latest build of this product (v23.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.