Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete only completes Function Names without it's Parameters #669

Closed
unkowncoder01 opened this issue Jan 10, 2025 · 18 comments
Closed

Comments

@unkowncoder01
Copy link

unkowncoder01 commented Jan 10, 2025

Hi,

Just wanna start off saying that I'm a complete beginner to the coding world, so I might not understand some of the coding terminologies if used. Anyway,

Demonstration of the Problem/or Lack of Feature (if it's considered as a missing feature)

  • Using "DllCall" AHK Function command as example
  • This extension & other AHK extension were used for demonstration

Expected Autocomplete Behavior

Expected Behavior

*Autocomplete completes Function Name + Parameters

Current Autocomplete Behavior

Current Behavior

_*Autocomplete completes Function Name only


I know that I can just install/create Snippets, however for Organizing Purposes I dont want to, because the autocomplete's list gets bloated with duplicated function names + snippets' logo/symbol are undesirable + snippets doesnt provide the function's autocomplete description from "ahk2.d.ahk" file

Therefore, is it possible to solve this problem/add this feature?

Cheers

@RaptorX
Copy link
Contributor

RaptorX commented Jan 10, 2025

I would not really like that feature. It is one of thre reasons I dont use some extensions.

If it is added (which I can see its value) It should be a setting that could be turned on/off

@thqby
Copy link
Owner

thqby commented Jan 10, 2025

When you type (, you will see the parameter prompt, and you can also make the complete ( automatically. I think this is the least side effect.

I would not really like that feature. It is one of thre reasons I dont use some extensions.

I don't like this behavior either. In the past, every time I complete, I need to remove these extra contents. Therefore, currently, only the #include segments that do not support parameter prompts will carry parameters during completion.

@unkowncoder01
Copy link
Author

unkowncoder01 commented Jan 11, 2025

Thanks guys for clarifying it's a feature not a bug.

Secondly, I understand the opinion of adding the feature would be undesirable (as I found out its a popular opinion amongst the coding community). However, I am sure most unexperienced users who's still new to the coding world or users who do wanna dive deep into the topic would like to have this feature for sake of simplicity. It would be nice to have as On-Off settings (for my workflow, it would help a lot), but overall it's up to the author or the votes.

Lastly, I know about enabling Complete Call feature or typing ( but all it does just adds brackets to the function name without adding parameters

Appreciate for the responses, you can close this thread if it's not gonna happen (at least help me add this feature for me personally instead of public release)

@thqby
Copy link
Owner

thqby commented Jan 11, 2025

1

There is no parameter prompt?

@RaptorX
Copy link
Contributor

RaptorX commented Jan 11, 2025

Lastly, I know about enabling Complete Call feature or typing ( but all it does just adds brackets to the function name without adding parameters

When you type ( a little pop up shows up telling you in which parameter you are right now.

image

As you add the commas the next parameter is highlighted. This is great because for new users you can get the benefits of knowing the parameter and then advanced users dont have to delete the parameters that they dont use.

@unkowncoder01
Copy link
Author

unkowncoder01 commented Jan 11, 2025

Ok I'm not sure if these are actually called Parameters or not (as I said I'm not familiar with coding terminologies so apologies for using wrong words)

what I meant by Parameters are these (red underlined)
Prompt Explain

*after autocomplete, not while typing

while typing yes I do get the autocomplete description (parameter prompt highlighting), but after typing when I hit TAB or ENTER it only completes function name with brackets, not the rest of it's options (red underlined)

Im not talking about the autocomplete description/parameter prompt, Im talking about after hitting TAB or ENTER to complete the function, it doesnt autocomplete/snippet the paramters/options too

@thqby
Copy link
Owner

thqby commented Jan 11, 2025

What is the purpose of completing the red line part?
In most cases, the variable names you use will not be the same as the red line, nor will you necessarily use all the content of the red line, and then you need to modify or remove them one by one.
If you want to know what parameters are needed and where they are, this information is available in the parameter prompts.

@unkowncoder01
Copy link
Author

unkowncoder01 commented Jan 11, 2025

I dont mind the extra work of deleting unnecessary content, however all I wanted was them to work as snippets

Using "MsgBox" command as example. This is what I want:
Last explaination

If not desired the extension doesnt need to have that feature publicly but would appreciate it if u help me implement the feature personally as On-Off setting, whether to enable everything in the autocomplete list (functions, etc.) to be behaved as snippets, or disable it like how the extension is originally designed

@thqby
Copy link
Owner

thqby commented Jan 12, 2025

As you showed, you can add your own code snippets.

Such as the green box, exists in some functions. Only string items are supported, and the corresponding completion items are extracted from the function document.
{37445654-91B4-49E5-B04A-E54201D26933}

Replace the following code in the server.js file.

qe.params[0].name.includes("|")?(ee.insertText=ee.label+"(${1|"+qe.params[0].name.replaceAll("|",",")+"|})",ee.insertTextFormat=Oe.InsertTextFormat.Snippet):(ee.insertText=ee.label+"($0)",ee.insertTextFormat=Oe.InsertTextFormat.Snippet)

to

ee.insertTextFormat=Oe.InsertTextFormat.Snippet,ee.insertText=`${ee.label}(${qe.params.map((p,i)=>`\${${(i+1)}:${p.name}}`).join(', ')})$0`

As mentioned above, complete the parameters when completing, and modify them here.

@unkowncoder01
Copy link
Author

Just replaced it. What does it supposed to do?

& what do you mean by "complete the parameters when completing, and modify them here"?

@thqby
Copy link
Owner

thqby commented Jan 12, 2025

This implements the feature of the first post.

@unkowncoder01
Copy link
Author

alright so here is a view of the replaced code in server.js file:
2025-01-13_02-27-37

but here is the final result:
overview

@thqby
Copy link
Owner

thqby commented Jan 12, 2025

set CompleteFunctionParens

@unkowncoder01
Copy link
Author

unkowncoder01 commented Jan 13, 2025

Works like a charm, much appreciated ^_^

Sounds ridiculous but last request, is it possible to allow the autocomplete list to replace completion from "ahk2.d.ahk" with snippets (that has same names) from "ahk2_common.json" while keeping the description/text prompt highlight from "ahk2.d.ahk"?

For example using "MsgBox", lets say I made a snippet in "ahk2_common.json" with prefix "Msgbox", then in project editor when typing and selecting "MsgBox" (the official one with the method/function symbol, not the snippet one) from the autocomplete list, can it apply completion from "ahk2_common.json" instead of "ahk2.d.ahk" while it's text prompt description is still active from "ahk2.d.ahk"?

Thanks in advance

@thqby
Copy link
Owner

thqby commented Jan 14, 2025

replace case"example": to case"snippet":A.snippet=se.trim();continue;case"example":

replace qe.params[0].name.includes("|")?(ee.insertText=ee.label+"(${1|"+qe.params[0].name.replaceAll("|",",")+"|})",ee.insertTextFormat=Oe.InsertTextFormat.Snippet):(ee.insertText=ee.label+"($0)",ee.insertTextFormat=Oe.InsertTextFormat.Snippet) to ee.insertTextFormat=Oe.InsertTextFormat.Snippet,ee.insertText=qe.snippet||ee.label+"($0)"

mmexport1736817120341

@unkowncoder01
Copy link
Author

unkowncoder01 commented Jan 14, 2025

Creating the snippet in .ahk file? even 10x better! Dope feature you've helped me implement.

Just faced one issue though, it snippets the whole description of the function (using "MsgBox" as ex):
@snippet
@description

@thqby
Copy link
Owner

thqby commented Jan 14, 2025

It depends on the placement location

@unkowncoder01
Copy link
Author

Thank u

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants