loganch / AutoIt-VSCode

AutoIt Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=Damien.autoit
MIT License
74 stars 25 forks source link

Function name suggestions interfere when creating a new function #184

Closed vanowm closed 1 year ago

vanowm commented 1 year ago

When typing Func myname it starts showing suggestions, pressing ( picks the first suggestion. It doesn't obey user's settings which key shall accept the suggestion (tab/enter)

loganch commented 1 year ago

It's possible that the reason for this is the createNewCompletionItem function in the _aicompletion.js file, which includes '(' as a commit character for function completions. I have yet to have it cause issues when creating new functions, though. Do tab and enter still work?

vanowm commented 1 year ago

Yes, tab/enter work as expected - accepting suggestion.

It is quiet annoying actually: AutoIt-VSCode_func_autocomplete

loganch commented 1 year ago

The idea was to have it work like it does in JavaScript. I've copied what you've shown in the gif and messed around the JavaScript side and I think I found the difference/potential solution.

I'm going to limit the completions that are available when the line starts with Func, since I noticed that any other type of completion suggestion is left out when attempting to create a function in JavaScript.

vanowm commented 1 year ago

and completion via '(' is probably not a good idea

loganch commented 1 year ago

I disagree and just think the implementation needed improvement, but I am going to add the option to disable it.

vanowm commented 1 year ago

https://github.com/loganch/AutoIt-VSCode/blob/08ece4a735b6fed8d45e1488b2c8570b0a79f521/src/ai_completion.js#L37 Doesn't seem to do anything actually...removing this line or changing the character has no effect, it still autocompletes with (

The actual autocomplete character is set in https://github.com/loganch/AutoIt-VSCode/blob/08ece4a735b6fed8d45e1488b2c8570b0a79f521/src/util.js#L98

Moving the changes from ai_completion.js to util.js seems to fix it.

loganch commented 1 year ago

Oh I see I got the case where the functions are created from user includes and not the standard ones (created by fillCompletion). I've added the check into util.js, but looks like it requires a window reload to take effect since fillCompletions is only used when the extension is activated.

vanowm commented 1 year ago

I'm still trying to understand how this works, but couldn't these be combined into one centralized function? so we don't have to maintain 2 different instanced of the same functionality?

loganch commented 1 year ago

The one in util.js is expecting a pre-built JS object to iterate through from each of the files under the completion folder and only runs when the extension is activated, thus why I didn't add a getter in there (I did at first, but found that it had no effect because the extension doesn't go back to it), while the one in ai_completion.js is made for the user's AutoIt scripts.

Of course, this is subject to change with the right thought and code applied to it. There's actually also signatureToCompletion() in util.js that could also be considered for doing something similar. I'll take a look into consolidating when I get some time.