Skip to content

Simplify generated launch.json #3321

Closed
Closed

Description

Hey,

VSCode dev here. This milestone I am looking into simplifing generated launch.json for various extensions microsoft/vscode#62851

The launch.json that Python generates is attached at the end. This is far too complex for the avarage user. I suggest to simplify it the following way:

  • DebugConfigurationProvider should use the quickPick to ask the user if he would like to debug the current file, attach, debug a python module, python django or debug python flask. Based on the user response only generate one configuration
  • Remove host: "localhost" from the attach, this should be the default value and should not be specified
  • If you strongly feel that the user should be asked what console to use, also ask that as a follow up question. IMHO this should not be asked, and just generate what you think is the best default experience
  • If the port is not standard also ask the user for it using quickInput, example
  • You are already contributing configurationSnippets which is great

If you agree with the suggestions I am making here I am also here to help with any potential questions you might have. The changes should not require a lot of work but will simplify the flow a lot imho.

{
	// Use IntelliSense to learn about possible attributes.
	// Hover to view descriptions of existing attributes.
	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [
		{
			"name": "Python: Current File (Integrated Terminal)",
			"type": "python",
			"request": "launch",
			"program": "${file}",
			"console": "integratedTerminal"
		},
		{
			"name": "Python: Attach",
			"type": "python",
			"request": "attach",
			"port": 5678,
			"host": "localhost"
		},
		{
			"name": "Python: Module",
			"type": "python",
			"request": "launch",
			"module": "enter-your-module-name-here",
			"console": "integratedTerminal"
		},
		{
			"name": "Python: Django",
			"type": "python",
			"request": "launch",
			"program": "${workspaceFolder}/manage.py",
			"console": "integratedTerminal",
			"args": [
				"runserver",
				"--noreload",
				"--nothreading"
			],
			"django": true
		},
		{
			"name": "Python: Flask",
			"type": "python",
			"request": "launch",
			"module": "flask",
			"env": {
				"FLASK_APP": "app.py"
			},
			"args": [
				"run",
				"--no-debugger",
				"--no-reload"
			],
			"jinja": true
		},
		{
			"name": "Python: Current File (External Terminal)",
			"type": "python",
			"request": "launch",
			"program": "${file}",
			"console": "externalTerminal"
		}
	]
}

Activity

  1. qubitron commented on Nov 13, 2018

    @qubitron

    Hi Isidor Nikolic (@isidorn), I like the direction, but want to make sure this doesn't add confusion for users who aren't using debug configurations. In our user tests we see the large majority of new users launch debugging from the Debug menu using Debug -> Start Debugging without using the debug activity view:
    image

    Which doesn't surface the ability to select/change the current debug configuration, so if the user made bad choices on their first attempt, debugging will be broken for the current workspace without an obvious way to fix it.

    The other concern I have is that currently adding another configuration takes me to a different experience (Python Configurations may not be in view), and doesn't make the new configuration the active one:
    image

    Which is problematic because:

    • If I wanted to fix or add a second debug configuration using the debug menu, it's not obvious how to use the new configuration I have just added.
    • If I wanted to add a second configuration, I get a different experience than the one I used to setup debugging initially

    So my suggestion would be that:

    1. Debug > Start Debugging (F5) continues to start debugging the current file without generating a launch configuration OR we provide a method to discover/change the active debug configuration from the debug menu (e.g. add a Set Active Configuration menu option next to Add Configuration)
    2. Add configuration would take users through the same menus , and the new configuration becomes active by default

    With regards to your suggestions above for the configurations:

    • We should prompt the user for port and host using the quickInput, the attach configuration is often used for remote debugging so both the port and host are non-standard
    • Agreed we should remove the console from the configuration options

    Let me know what you think of the above!

  2. isidorn commented on Nov 14, 2018

    @isidorn
    Author

    Dan Taylor (@qubitron) thanks a lot for you quick reply. Very good points.

    1. Debug > Start Debugging should not generate a launch.json - exactly what you are already doing. That is perfectly fine and node is following the same practice. This issue is more about simplifying it for users who want more advanced debugging and are inside launch.json. We should not change anything for the simple case which nicely works
    2. I agree, I have something on the plan for this milestone. Though this is just an exploration for now Debug: explore dynamic snippets vscode#63121 you can subscirbe on that issue if you would like to continue the discussion there

    Once you have some version of the quick pick help in launch.json generation working let me know and I can try it out to provide more feedback.

    Apart from this please let me know if there is anything else on the vscode side which we should add that could potentially make the debug setup for pyhton much easier. I do not know what are the biggest pain points here for the python users when it comes to configuring debugging.

  3. qubitron commented on Nov 14, 2018

    @qubitron

    Sounds good!

    @Microsoft/pvsc-team while we're working on this I have a few other suggestions:

    • Let's remove (integrated terminal) from the title of the debug configuration, just have "Python: Current File"
    • For flask/django apps, attempt to locate the app.py/manage.py files and prompt the user for the path to them if not found
    • Any other common config variables you think we should prompt for?
  4. brettcannon commented on Nov 14, 2018

    @brettcannon
    Member

    Related may be #2710

  5. 24 remaining items

  6. DonJayamanne commented on Mar 29, 2019

    @DonJayamanne

    Luciana Abud (@luabud) Dan Taylor (@qubitron)

    • Left the leading * in front of Python to ensure it is placed on the top.
    • Removing * will place Python at the bottom along with others.
    • However - We can control the pre-selection of the Python item in the list, but VSC will decide whether to display that item as pre-selected or not.

    Note The item Python will appear when:

    • Users manually attempt to edit the launch.json file
    • Users click the Add Configuration button in launch.json file.

    Option 1: With *

    debug

    Option 2: Without * (still works)

    debug2

  7. DonJayamanne commented on Apr 8, 2019

    @DonJayamanne

    Whats been implemented:

    • When launch.json does not exist and one attempts to debug, then user will be prompted to pick a debug configuration
    • When launch.json does not exist and one attempts to create a debug configuration (i.e. launch.json), then user will be prompted to pick a debug configuration and the launch.json created will contain that debug configuration
    • When editing an exiting launch.json user will have the ability to choose a debug configuration from the above UI (we now display the standard snippets and display an additional Python item which when selected will display the prompts)
  8. ericsnowcurrently commented on Apr 8, 2019

    @ericsnowcurrently

    I've verified that this works;

    1. open folder that does not have a launch.json already
    2. go to debug panel
    3. click on gear
      • opened: "Select Environment" quick pick
    4. select "Python"
      • opened: "Debug Configuration" quick pick with 6 options
    5. select "Python File"
      • created (and opened): launch.json with a single entry

    Auto-completion in the launch.json works too, though it didn't let me select one of the original 6 pre-built configs.

  9. DonJayamanne commented on Apr 8, 2019

    @DonJayamanne

    Auto-completion in the launch.json works too, though it didn't let me select one of the original 6 pre-built configs.

    Eric Snow (@ericsnowcurrently) what do you mean by this?

  10. ghost removed on Apr 8, 2019
  11. ghost removed
    needs proposalNeed to make some design decisions
    on Apr 8, 2019
  12. locked as resolved and limited conversation to collaborators on May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions