Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify generated launch.json #3321

Closed
1 of 5 tasks
isidorn opened this issue Nov 13, 2018 · 15 comments
Closed
1 of 5 tasks

Simplify generated launch.json #3321

isidorn opened this issue Nov 13, 2018 · 15 comments
Assignees
Labels
area-debugging feature-request Request for new features or functionality

Comments

@isidorn
Copy link

isidorn commented Nov 13, 2018

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"
		}
	]
}
@DonJayamanne DonJayamanne added feature-request Request for new features or functionality needs PR area-debugging important Issue identified as high-priority needs proposal Need to make some design decisions labels Nov 13, 2018
@qubitron
Copy link

qubitron commented Nov 13, 2018

Hi @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!

@isidorn
Copy link
Author

isidorn commented Nov 14, 2018

@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.

@qubitron
Copy link

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?

@brettcannon
Copy link
Member

Related may be #2710

@DonJayamanne
Copy link

DonJayamanne commented Dec 17, 2018

Changes to be made:

  • Remove default config item Python: Current File (External Terminal), leave it as a configuration snippet
  • Change title of Python: Current File (Integrated Terminal) to Python: Current File.
    • Remove console from this snippet and default config entry
  • When user clicks the add config button then:
    • Display pick list
    • If django is selected, auto populate program, and ask user for input
    • If flask is selected, auto populate program, and ask user for input
    • If attach is selected, auto populate port and host, and ask user for input

DonJayamanne added a commit that referenced this issue Dec 18, 2018
For #3321 

* Created a separate PR to refactor before introducing changes related to 3321
* Easier to review and merge (smaller changes)
@DonJayamanne
Copy link

DonJayamanne commented Dec 19, 2018

Overview

  • Settings dropdown displays multiple options
  • Currently you can only select one debug configuration at a time (we can extend this in the future)
  • Later we can use this same UI to configure django (use live loading or not, etc)

Back button (in case you accidentally select wrong config)

backbutton

Debug Python file

pythonfile

Debug Python module (with validations)

module

Remote debugging (with validations)

attach

Django (with validations for file path)

  • Accidentally selected module, but all is not lost, i can click back button
  • Opening debug configuration using command palette so you can see explorer view
  • The path to manage.py is validated, as you can see the path is /app/manage1.py (and not app/manage.py)
    django

Flask

flask

Pyramid

pyramid

@isidorn
Copy link
Author

isidorn commented Dec 20, 2018

Very cool work @DonJayamanne
I would be interested in user feedback on this.
I personally would try to lower the number of quick input questions in some cases for instance program output question seems it might be too much. But you will figure it out exactly once ou try it out and get feedback.

@ericsnowcurrently
Copy link
Member

@DonJayamanne, I tried master and found some small problems:

  • after the launch.json is created the pull-down doesn't get updated

It still says "No Configurations"; the new config is not added. However, it does fix itself once I click the green arrow.

  • clicking "Add Configuration..." does not trigger quick input

This echos what @qubitron said:

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:

  • users are less aware of unused/possible options (e.g. the removed ones)

I suppose this is not a new problem. However, we're including fewer of the defaults. It would probably make sense to include a small comment in the launch.json referring users to a doc page that enumerates the various options.

@ericsnowcurrently
Copy link
Member

FWIW, otherwise the change looks good. :)

@luabud
Copy link
Member

luabud commented Mar 26, 2019

This should appear when starting to debug with F5 when no configuration exists

@DonJayamanne
Copy link

DonJayamanne commented Mar 27, 2019

Prescribed solution:

@DonJayamanne
Copy link

DonJayamanne commented Mar 29, 2019

@luabud @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

@DonJayamanne
Copy link

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)

@ericsnowcurrently
Copy link
Member

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.

@DonJayamanne
Copy link

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

@ericsnowcurrently what do you mean by this?

@ghost ghost removed needs PR needs proposal Need to make some design decisions labels Apr 8, 2019
@ericsnowcurrently ericsnowcurrently self-assigned this Apr 9, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

7 participants