Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ease-dev] ScriptShell completion insert

Hi,

I debugged the problem with the double insertion when using auto-completion with the ScriptShell, found the issue and boy, it's a mean one ;-)

First off, Vidura's code works fine. Unfortunately so does the original...

The ContentProposalModifer class subclasses ContentProposalAdapter and passes the required parameters to the parent's constructor.
These parameters include among others:
  • The ScriptShell's input
  • The IContentProposalProvider (the CompletionProviderDispatcher)
  • The activation KeyStroke
  • The auto-activation characters.

What happens now, is that both the new implementation as well as the original listen for the keystrokes in the ScriptShell. Since both of them will handle the same key inputs they will also calculate the same proposals and insert the same code. It looks like you are only using one popup, but actually you are using 2 overlapping that just happen to get the same key events simultaneously.

I did a simple test where I inverted the order of the displayed proposals for the new implementation:
If you type 'get' and trigger the autocompletion you will see a popup with 2 suggestions (getModule and getScriptEngine). If you select the first one the included code will be 'getModuleScriptEngine'. Since one popup has the inverted order it calculates the string to be included for a different proposal.

I found a quick-and-dirty workaround though:
When calling the parent constructor we must use null for the keystroke and a hard to get auto-activation character.
If we only give null for the keystroke and an empty array for the activation characters the parent will auto-trigger and immediately open a popup. This is also the situation where you can see that actually 2 popups are opened independently. 
To fix this issue it is necessary to also give at least one auto-activation character. For testing I chose (char) 0xFF and this seems to fix the problem as long as no character 0xFF (character, not string) is entered in the ScriptShell.

If both Christian and Vidura are okay with the fix,  I can commit it. If you want another solution I guess we will need some major (!) refactoring.

Best regards,
Martin


Back to the top