mark-wiemer-org / ahkpp

AutoHotkey Plus Plus (AHK++) - AutoHotkey v1 and v2 support for VS Code
https://marketplace.visualstudio.com/items?itemName=mark-wiemer.vscode-autohotkey-plus-plus
Other
152 stars 10 forks source link

AHK V1 files language mode is always set to `AutoHotkeyV2` #396

Closed GaryAtlan82 closed 1 year ago

GaryAtlan82 commented 1 year ago

Since update to the latest version V1 files, .ahk, are recognised as V2 files, by this I mean the current language mode is set to AutoHotkeyV2. I have yet to start using V2, a few libraries that I count on have yet to ported over to V2, so I use V1 only for now.

Is there setting to prioritise V1, or to reserve .ahk extension for V1.

The following is typical of the first few lines of my .ahk files. Is this not enough to know this is for AHK V1 files?

#singleinstance, force
#Persistent
#NoEnv
#Warn, All, OutputDebug
#MaxHotkeysPerInterval 500
SetBatchLines, -1
DetectHiddenWindows, On
SetTitleMatchMode 2 
; SetTitleMatchMode, RegEx

#include <TapHoldManager>
#Include <FindText>
#include <UIA_Browser>
Latest AutHotkey V1
Latest AHK++ Extension Update
Code Version: 1.78.1 
Code Electron: 22.5.1
Code Chromium: 108.0.5359.215
Code Node.js: 16.17.1
Windows 11
mark-wiemer commented 1 year ago
  1. Open a .ahk file
  2. F1 -> "Change language mode"
  3. Configure file association for .ahk
  4. AutoHotkey v1

Alternatively, you can rename your .ahk files to have .ah1 or .ahk1 extensions

Finally, you can add #Requires AutoHotkey v1 to each of your files--that's how the extension determines language mode for now, as it's the most definitive and simple way to do things :)

I've updated the v5 changelog with all of these notes as it wrongly claimed these files defaulted to AHK v1--thank you for reporting this.

GaryAtlan82 commented 1 year ago

Hey thanks!

Alternatively, you can rename your .ahk files to have .ah1 or .ahk1 extensions

This would be the most sensible thing to do but I always end breaking something when I mass rename files. For example paths inside scripts ending with .ahk.

F1 -> "Change language mode"

I would like to avoid doing this, I understand in one of situations though.

Configure file association for .ahk

What do you mean by this? Are you reffering to the File Explorer "Open with..." feature? I was not aware you can fix this issue here, if so this would be an ideal fix for people who use V1/V2

mark-wiemer commented 1 year ago

When the "change language mode" picker appears, you have the option of changing it for just that one file or to "configure file association for .ahk", (i.e. all .ahk files). Your choice is saved in your settings and you should only have to do it once and it should apply to all your projects!

GaryAtlan82 commented 1 year ago

I was not aware of this at all. I will give this ago tomorrow. Thanks!

GaryAtlan82 commented 1 year ago

Hey, I was able to give your solution ago and sure enough you was right. It was a much better solution than the awfull one I had in mind. Thanks allot for that.

fade2gray commented 12 months ago

@mark-wiemer May be best to create a separate pinned issue for this https://github.com/mark-wiemer-org/ahkpp/issues/396#issuecomment-1676525716? - I can see this being a frequent issue for those who have not updated yet.

mark-wiemer commented 12 months ago

Good idea. I'm a bit busy rn but I will update the bug template shortly and pin an FAQ bug for easy access :)

wenfangdu commented 7 months ago

Another way is to paste:

{
  "files.associations": {
    "*.ahk": "ahk"
  }
}

In to the vscode settings.json.

mark-wiemer commented 7 months ago

To do a full uninstall and re-install of AHK++: There are some special locations where VS Code keeps a copy of all extensions, even after you uninstall them. I find those locations using the "Everything" search engine. Looks like it's under C:\Users\%user%\.vscode\extensions\mark-wiemer.vscode-autohotkey-plus-plus-5.0.3 by default, try removing that folder entirely and then uninstalling.

Note that your settings will be preserved as they're stored in C:\Users\%user%\AppData\Roaming\Code\User\settings.json :) (note this folder is hidden in File Explorer by default)

mark-wiemer commented 3 months ago

Ref #445 for cleaner instructions :)

doggy8088 commented 1 month ago

Another way is to paste:

{
  "files.associations": {
    "*.ahk": "ahk"
  }
}

In to the vscode settings.json.

I think this setting should be mentioned on extension page: https://marketplace.visualstudio.com/items?itemName=mark-wiemer.vscode-autohotkey-plus-plus