question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prompt the user for the startup script when pressing F5 on a Dart project (rather than opening launch.json)

See original GitHub issue

Flutter works better now (no launch.json needed, just press F5) but with Dart we need to know which script to use.

I suggest when we don’t have a program we either open a file open dialog or give the user a pick list of all .dart files inside the bin, test and tools folders to pick from (@devoncarew, @mit-mit any preferences?) and then ensure this gets stashed into launch.json so they don’t have to do it on every F5.

If the current open file is already inside bin/test/tool maybe we should just assume it and skip the prompt.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:33 (30 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, Sep 19, 2018

@pulyaevskiy FYI - it’s not a complete solution for this, but #1206 adds a “Dart: Rerun Last Debug Session” command (bound to Cmd+Shift+F5/Ctrl+Shift+F5 when not already debugging) which might help a little. It re-runs the last debug session, with ${file} etc. having been resolved.

So, if you have ${file} (or nothing) in your launch.json such that F5 runs the open file, then you switch to another file and run this command, it’ll re-run the same file as original. This also means if you click a Run/Debug Codelens link then end up jumping into the code being tested, you can re-run the same test (or group, or file, or whatever) from wherever you are without switching back to the test file.

1reaction
DanTupcommented, Mar 20, 2018

v2.11 Beta 2 has some additional changes that solves some (but not all) of the things in here. If you have no launch.json and hit F5 then your current file will be invoked if it’s inside test/bin/tool.

Thoughts for improving this are detecting if the script has a main method in it and if not, prompt the user:

The current file cannot be executed, would you like to run the last run script? [ Run bin/main.dart ] [ Create launch.json ]

bin/main.dart would be replaced with the last file that was run. We can add a setting to “always run the last run script if the current file is not executable” which you can set globally, or at workspace level. It would function the same as clicking the left button on the prompt above. If there is no last run script we’ll still show a prompt, but change the text somehow (maybe take a guess at the script to run) - I don’t want to just create the launch.json because once it’s created, you have to maintain it (and I think F5-without-launch.json is best for most people).

@pulyaevskiy What do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prompt the user for the startup script when pressing F5 on a Dart ...
Prompt the user for the startup script when pressing F5 on a Dart project (rather than opening launch.json)
Read more >
when press ctrl + f5 open launch.json and my code is not run ...
this photo when I was run my dart code last night ctrl + f5 worked correctly and today happen this problem! flutter ·...
Read more >
Launch Configuration - Dart Code - Dart & Flutter support for ...
You can open your launch configuration file by clicking on the Debug side bar and then either the cog icon at the top,...
Read more >
Language Server Extension Guide - Visual Studio Code
The HTML Language Client and PHP Language Client are normal VS Code extensions written in TypeScript. Each of them instantiates a corresponding Language ......
Read more >
Is Your VS Code Extension Slow? Here's How to Speed it Up!
json; F5 debugging the tests with the launch.json. The approach has me compiling both with webpack and tsc for the tests ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found