mark-wiemer-org/ahkpp

VsCode Does not Find Formatter

Closed this issue · 13 comments

Description

I think since the last Update the formatting ist not Working anymore for Version 1

image

I tried reinstalling the extension. But did not Help.

image

Here ist the settings.json

image

Same for me when editing *.ahk files but the error says "ahk2" files (not sure where it gets that from):
image

I also tried setting the formatter manually in the settings to no avail:

"[ahk]": {
  "editor.defaultFormatter": "mark-wiemer.vscode-autohotkey-plus-plus"
},
"[ahk2]": {
  "editor.defaultFormatter": "mark-wiemer.vscode-autohotkey-plus-plus"
},

@Chutriel235, thanks for reporting this, but I'm not able to reproduce the issue. Can you try disabling all other extensions temporarily? I can post detailed repro steps later today.

@CombeeMike, at the bottom of VS Code, you should see the language. It may default to AHK v2 for some files, but you can update it to AHK v1 manually:

Note how v2 has a green icon:
image

Clicking the language allows you to change language mode:
image

And v1 has a blue icon:
image

@mark-wiemer I deactivated all other extensions, but same issue. I startet the same way for me as in CombeeMikes case. At first i had the v2 message. I change in the right corner to .ahk = ahk1 version and all updatet to blue as expected. Then i had the formatting problem.

image

@CombeeMike

I am now just running the previous version. That works as expected.

image

Hm, that's really strange. I can try to release some incremental versions to see if they work for you. Honestly, I reset my whole setup by doing the following. ⚠️ Warning: this may delete your settings, keyboard shortcuts, snippets, and other customizations.

  1. Deleting C:\Users\markw\.vscode\extensions\mark-wiemer.vscode-autohotkey-plus-plus-5.0.0
  2. Uninstalling VS Code
  3. Reinstalling VS Code
  4. Disabling all other extensions
  5. Installing AHK++ (latest version, 5.0.0)

Everything worked for me both before and after I did those steps. I'm not sure what else I can do to try to repro the issue, unfortunately.

Here's what I'll try when I have some time:

  1. Release incremental builds between 4.1.0 and 5.0.0 to see if we can pinpoint versions that do or don't work
  2. Release a separate formatting extension to see if we can workaround this issue in the meantime
  3. Look at gathering profiling data and logs to see if maybe issues are occurring in the extension that aren't visible here

For now, I'm going to push some other bugfixes. Maybe updating to 5.0.1 or 5.0.2 will magically resolve the issue, who knows?

@mark-wiemer

thank you very much for your effort.

For me its not very critical, i can just use the old version for some time. So i think looking forward and just fixing other stuff, might be acually the best way. And chances are, this strange bug will ge caught in the process or some unknown relationship gets discovered.

Updating to 5.0.1 fixed this for me ✅.

Also, I added "files.associations": { "*.ahk": "ahk" } to my settings since VSCode otherwise defaulted to above mentioned ahk2 which is still not working with the formatter (not even sure if it should...).

Thank you very much for the fast response & your great effort!

@Chutriel235 thanks for your patience.

@CombeeMike AHK v2 formatting is still not available, see #381 for progress there--it may take some time.

Please try the new AutoHotkey v1 Formatter extension. It should work standalone or side-by-side with any AHK++ version. Be sure to update your settings so that it's the default formatter.

Additionally, you can try updating settings.json to update the default formatter for AHK v1 scripts:

{
    "[ahk]": {
        "editor.defaultFormatter": "mark-wiemer.ahk-v1-formatter"
        // "editor.defaultFormatter": "mark-wiemer.autohotkey-plus-plus" // uncomment to use AHK++
    }
}

Please try the new AutoHotkey v1 Formatter extension. It should work standalone or side-by-side with any AHK++ version. Be sure to update your settings so that it's the default formatter.

Additionally, you can try updating settings.json to update the default formatter for AHK v1 scripts:

{
    "[ahk]": {
        "editor.defaultFormatter": "mark-wiemer.ahk-v1-formatter"
        // "editor.defaultFormatter": "mark-wiemer.autohotkey-plus-plus" // uncomment to use AHK++
    }
}

I followed all the steps you suggested, but it still didn't work. Feeling helpless, I decided to click "Formatierer installieren..." in VSCode when prompted.
259043061-c99d7950-4941-49e7-bf66-91e08331c9e9

Then, VSCode searched for "category:formatters ahk2," and I installed the "AutoHotkey v2 Language Support" extension.
屏幕截图 2023-09-03 043818
Strangely, something unexpected happened; VSCode was able to format properly. However, the odd thing is that the formatting extension used was "AutoHotkey Plus Plus." Once everything was working as expected, I tried disabling "AutoHotkey v2 Language Support." Unfortunately, to my disappointment, everything went back to how it was before, with the message indicating that the formatter was not installed.

@frank-hank, what language mode were you trying to format, AHK v1 or v2? If VS Code search for ahk2 formatters I'd think that's because the file was v2 (green icon). My extension only supports v1 (blue icon). If installing thqby's extension made things work, that's likely because thqby's extension was being used as it was a v2 file. Note the instructions you quoted are for language ID ahk, which is AHK v1. You probably now have a setting [ahk2]: { "editor.defaultFormatter": "thqby..." } or similar, and without thqby's extension, there is nothing to format v2 files.

@frank-hank, what language mode were you trying to format, AHK v1 or v2? If VS Code search for ahk2 formatters I'd think that's because the file was v2 (green icon). My extension only supports v1 (blue icon). If installing thqby's extension made things work, that's likely because thqby's extension was being used as it was a v2 file. Note the instructions you quoted are for language ID ahk, which is AHK v1. You probably now have a setting [ahk2]: { "editor.defaultFormatter": "thqby..." } or similar, and without thqby's extension, there is nothing to format v2 files.

I'm sorry, I forgot to mention that my AHK version is v1, and I don't have v2 installed on my computer. The file extension for my AHK scripts is also ".ahk". But for some reason, VSCode is showing search results with "category:formatters ahk2". I checked the settings.json file in VSCode, and there is no configuration for the ".ahk2" extension.

Thanks @frank-hank. What color is the icon for the file--green or blue? Green means VS Code thinks the file is AHK v2, and blue means v1. .ahk files default to v2, that may be your issue. See my reply above--you can click the language in VS Code to change it from v1 to v2--this changes the icon color and whether VS Code tries to format it.

Note how v2 has a green icon:
image
Clicking the language allows you to change language mode: image

And v1 has a blue icon: image

Thanks @frank-hank. What color is the icon for the file--green or blue? Green means VS Code thinks the file is AHK v2, and blue means v1. .ahk files default to v2, that may be your issue. See my reply above--you can click the language in VS Code to change it from v1 to v2--this changes the icon color and whether VS Code tries to format it.

Note how v2 has a green icon:
image
Clicking the language allows you to change language mode: image
And v1 has a blue icon: image

thanks, I manually changed it to v1, and then it succeeded. It turns out it was a problem here.
屏幕截图 2023-09-13 080834