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

[QUESTION] How to open currently selected file when launch.json is present? #569

Closed RaptorX closed 2 months ago

RaptorX commented 2 months ago

At the present if you create a launch.json file and have a particular file open that is not listed in the launch.json file, then you cannot use your extension to debug it (Unless I am missing something).

Opening the default debugger with the F5 hotkey (if not changed) would read from launch.json obeying whatever is selected in the status bar for the debugger.

Clicking the extension button reads the launch.json file but doesn't obey the status bar selection. That means that even if you have one configuration for ${file} you will have to always select it from the status bar and then press the hotkey for the default debugger and not your extension (if that is not the first configuration).

So what's the easiest way to debug the currently opened file with your extension?

PythonYunfei commented 2 months ago

Through vscode-autohotkey-debug and adding debug settings to a workspace configuration can solve this. image image

thqby commented 2 months ago

I think the easiest way is to pop up a selection box before the start of the debugging session.

RaptorX commented 2 months ago

Through vscode-autohotkey-debug and adding debug settings to a workspace configuration can solve this.

No, I already do that. Thats 3 actions: first setup the launch.debug (1 time thing), switch to the file, then pick it from the selector in the status bar... then whats the point of having a button at the top at all?

I think the easiest way is to pop up a selection box before the start of the debugging session.

I think we can have a second button: One for debug with launch settings, and one that debugs the current file.

that way you dont have to change the code, and we keep it as a 1 click thing instead of having to go through additional steps just to launch the open file.

Not sure if you like that idea though.

Current work around

I have the autohotkey plus plus extension installed, its button launches the currently opened file, yours opens the launch.json

image

The problem is that im about to uninstall autohotkey plus plus because i dont code in v1 at all anymore. But I havent uninstalled it because I will lose that functionality. Its not a big deal, but it tends to be annoying when you have test modules and different scripts that you just want to run quickly as a test.

PythonYunfei commented 2 months ago

@thqby 如果要搞,就搞成可选设置。仅当设置被勾选后,新按钮才会出现。 另外下面图片中的设置,也建议改为可选的。建议该设置前面也加个复选框,只有复选框勾上后 设置才会生效。 image 这样如果有其他调试插件也实现了相同功能,就把该复选框的勾 取消掉。这样就可以避免和调试插件冲突。毕竟这两个特性本该属于调试插件该干的事,不属于本插件该干的事

RaptorX commented 2 months ago

I just noticed that i can setup the launch.json to have the 1st item to be the current file with ${file}, then add other configurations. (@PythonYunfei pointed part of this workaround out)

Then if I press F5, it will always open the current file. I then made sure the Ctrl + F5 hotkey opens the default debugger instead of yours.

Now your button runs the current file, and Ctrl + F5 obeys whatever I have selected in the statusbar as the currently debugging launcher file.

A bit annoying but is the best i can do atm.

So the two ideas (besides the above workaround) would be: • Have 3 buttons, 1 run the current file, 2) run and debug the current file, 3) launch from launch.json • Find a way to have the ahk2.debug command obey whatever is selected in the statusbar

thqby commented 2 months ago

There are commands to start the debugger from the configuration of your choice, but this is language insensitive. This may have started the C ++ or Python debugger.

RaptorX commented 2 months ago

There are commands to start the debugger from the configuration of your choice, but this is language insensitive. This may have started the C ++ or Python debugger.

So there is no actual API at the moment for that? I see.

Well, then its just either an additional button or the workaround that i am already using. Alright. Ill be closing this topic for now.

Thanks for everything!