Some followup questions ...
My launch.json doesn't seem to load automatically. i.e. I load my script in VS Code by right-clicking and saying "Open in Code". I click Run and Debug and I'm prompted to open a folder and I open the folder that my script is already in and THEN I see the options from my Launch.json file. Seems like an extra and unneccesary step. Is there a way to avoid this?
UPDATE: https://code.visualstudio.com/docs/debugtest/debugging-configuration#_global-launch-configuration - according to this, I should be able to put the info in the settings.json file and have it load, but it didn't seem to work for me. This should allow it to automatically load the launch.json configuration. It wouldn't be a good idea if I were using VS Code for ESTK and Python and C#, but for only using it with ESTK, it SHOULD be more convenient, (but it doesn't seem to work ...)
UPDATE2: Preferred solution seems to be to Open the scripts folder - which seems to work, but seems a bit redundant since I already have the script I want to test/run open in VSCODE. Alternative seems to be to press F5, which works, but (I think) loads the default launch.json option, but since I currently only have one ...
Any idea why breakpoints aren't working in code? I can set them, but they seem to be ignored.
I was incorrect about having to save all scripts in Code. There will be a prompt to save the script, but you can just click cancel and the script will run.
Q2 - Is Launch the equivalent of clicking the green triangle in ESTK? That is what I am used to and probably why I am getting confused. If I click launch, the scripts runs and I can view all the debugging options. If I click Attach, I have to click "Eval in Adobe FrameMaker 2022 (main)" before anything happens (visibly). To me, it seems like an additional mouse click for no benefit - like having to open a folder in order to have my launch.json load.
Answering most of my own questions:
Opening VS Code:
I have previously used ESTK and Notepad++ among other editors. VS Code seems to be somewhat between ESTK and Notepad++ as follows:
- If I open ESTK without selecting a file, I get a blank window. If I don't have ESTK open and I click a .jsx file and select Open with ESTK, that file opens. If I had five files open in ESTK when I closed the program, that SESSION is gone. The files are saved if I saved them before closing, but ESTK only opens the files I specifically tell it to.
- Notepad++ remembers sessions. If I have "a.jsx", "b.jsx", "c.jsx", "d.jsx" and "e.jsx" open in NP++ and close the program and I right-click "a.jsx" and select open with Notepad++, it will go to the previously open "a.jsx" and my other 4 files will still be there. If I don't have NP++ open and I right-click and open "f.jsx", it will open "f.jsx" along with the previous 5 files I left open when I last closed it.
- VS Code seems to be missing one of the steps. If I open 5 files in VS Code and close the program and then open VS Code from the start menu - all five files are loaded and my launch.json works. If I don't have VS Code open and I right-click "a .jsx" file and select "Open with Code", that file opens, but my launch.json does not work. I have to select File>Open Folder and select my project folder and then my launch code works and the other four files open. For my usage, I added a shortcut to VS code in my scripts folder. Then it was a matter of re-training myself to open the shortcut first rather than right-clicking a file and selecting "open with code".
BREAKPOINTS:
- Breakpoints DO work for me (sometimes!!!). The key issue here is you have two options: RUN or RUN AND DEBUG. Usually, I was clicking Eval in Adobe at the bottom of the screen and that runs the script without checking for breakpoints. The green triangle in run and debug (with Launch) works -
or if in doubt the top menu Run>Debug should always work.
Personally, I'm still not seeing when I might want to use debug instead of launch, but it might have more to do with the type of code I am developing. Launch works well for me and I'm content to leave it at that.
Additionally, the line numbers and the code window both have a white background by default. I was finding it difficult to know where the code window starts and whether I had extra spaces at the start of a line. I modifed my settings.json file and it helped a lot. If you want to change it, go to preferences (Ctrl-Shift-P) and search settings.json and select Edit User Settings.json and add the following lines:
// https://stackoverflow.com/questions/41055612/how-to-change-the-gutter-background-colour-in-vs-code,
"editor.rulers": [ 0 ],
"workbench.colorCustomizations": {
"editorGutter.background": "#888e9228" // your color here
},
"editor.renderWhitespace": "all",
You can change colors and options, but this will give you a starting point for where to look!!!
Finally - I found this a bit odd, but it is probably default behavior: In one of my scripts, I used "If (some condition){" <Initial caps> instead of "if (some condition){" <lowercase>. When I tried to debug from VS Code, it opened the script in ESTK and said "If is not a function." I was surprised ESTK opened, although that makes sense, and I was surprised VS Code didn't flag it as an error.
Thanks to all and especially @m1b for the assistance!