thqby / vscode-autohotkey2-lsp

Autohotkey v2 Language Support using vscode-lsp.
https://marketplace.visualstudio.com/items?itemName=thqby.vscode-autohotkey2-lsp
GNU Lesser General Public License v3.0
219 stars 21 forks source link

`{Alt Down}` snippet produces `{{Alt Down}` when invoking it with `{` #286

Closed zachpoblete closed 1 year ago

zachpoblete commented 1 year ago

brace-snippet_5s

In this case, you need to invoke it with { because of the b at the start.

This goes for any of the other brace snippets like {Shift Up}, {Click}, etc.

RaptorX commented 1 year ago

Why would you want the snippet trigger to contain {}??

I bet you wouldn't have that issue if your trigger was .alt for example.

zachpoblete commented 1 year ago

Thanks for your .alt suggestion. Just to clarify, these brace snippets actually come with the extension. You can find them at %USERPROFILE%\.vscode\extensions\thqby.vscode-autohotkey2-lsp-1.9.0\syntaxes\ahk2_common.json (replacing 1.9.0 with your version of the extension).

image

In my opinion, the triggers for snippets like {Alt Down} should contain {} because that is how users would first think to trigger them. If the trigger for {Alt Down} were .Alt Down, that would have to be explained in the documentation. It's easier for users if what they intuitively think would work, using {Alt Down} as the trigger, works.

In solving the original issue, I see two possible options.

  1. Change the trigger of {Alt Down} to .Alt Down, but that runs into the issue of intuitiveness.
  2. Find a way to correctly trigger {Alt Down} with {Alt Down}.

Again, thanks for your suggestion. I'll try it out if option #‎2 turns out not to be possible.

RaptorX commented 1 year ago

I thought you created it yourself.

well, you dont have to type the {} toget those suggestions. I just typed alt and selected it from the list and got it to show up correctly.

GIF 2-14-2023 14-01-15

zachpoblete commented 1 year ago

Yup, that works in most cases, except in the specific case I opened the issue about.

Send('b')

If I want to insert {Alt Down} after b by just typing the letters, the suggestion would never pop up.

Send('balt')

because balt isn't a trigger.

Also, in your gif, {Alt Down} isn't the 1st suggestion but the 3rd, so typing just the letters takes more time.

RaptorX commented 1 year ago

that is correct, in the first case you'd have to add a space and later remove it. probably the way to go is that the { shouldnt be auto closed if we are inside of a string (same with other auto close characters like [ or ( but that would be annoying in other cases).

not sure if that is possible though, @thqby would confirm how that works.

thqby commented 1 year ago

Remove the { in the completion to adapt to all situations

PythonYunfei commented 1 year ago

Remove the { in the completion to adapt to all situations.

I think the issue can be considered. As inputting "se" will automatically complete "Send", rather than "sSend". The same should be applied to "{A" too, just like what "se" does.