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

Support targeting different terminals for running/debugging #99

Closed
DanTup opened this issue Aug 16, 2016 · 22 comments
Closed

Support targeting different terminals for running/debugging #99

DanTup opened this issue Aug 16, 2016 · 22 comments
Labels
in cli Relates to running Dart CLI scripts in debugger Relates to the debug adapter or process of launching a debug session is enhancement
Milestone

Comments

@DanTup
Copy link
Member

DanTup commented Aug 16, 2016

@devoncarew Looks like this is going into September release, so probably around 6 weeks away:

microsoft/vscode#10574

The initial terminal API is marked for August.

We need to check whether we can require that version of Code when it happens, else we'll have to make this conditional.

Marking as v1 because I'd love to have it, but it's probably wishful. If we end up wanting to ship a v1 before this is usable, we'll bump it back.

@DanTup DanTup added this to the v1.0 milestone Aug 16, 2016
@DanTup DanTup added external / blocked blocked on vs code / lsp / dap Requires a change in VS Code to progress labels Aug 20, 2016
@DanTup DanTup modified the milestones: v1.0, 0.10 Aug 27, 2016
@DanTup
Copy link
Member Author

DanTup commented Aug 29, 2016

Seems that MS have done debug support for integrated terminal; I've asked if they might ship it in the August release but we should branch this from debugger for now just in case it doesn't.

Feature info: microsoft/vscode#10574
Implementation in the Node debugger: microsoft/vscode-node-debug#85

We'll need to bump our code version to 1.5 for this and the debug adapter/protocol versions too. I believe it'll work in Insiders builds from Monday.

@DanTup DanTup removed external / blocked blocked on vs code / lsp / dap Requires a change in VS Code to progress labels Aug 31, 2016
@DanTup
Copy link
Member Author

DanTup commented Aug 31, 2016

@devoncarew I had a quick look at this to see how complicated it could be. I've pushed a minor change to a branch as a PoC. It seems to mostly work! There are some issues:

  1. Can't get stdout when launching, so we need to set the observatory port up-front (I'm currently leaving it as default, but we'll probably have to randomly generate? Need to check if MS do something better in their node one)
  2. If you launch "without debugger", Code doesn't know when it terminates and so appears to be stuck "running" even when it terminates (there's some dirty hack in their node sample that polls for the process; wonder if we could do something better?)
  3. I've left the original code as runStandalone but if we can confirm that Code >=1.5 always sends supportsRunInTerminal=true and the constraint changes will disallow installing in 1.4, we could ditch all that.

Interested in your thoughts! Feel free to make changes if you want; it's unlikely I'll get any more time on this before late Friday.

@DanTup
Copy link
Member Author

DanTup commented Aug 31, 2016

Seems like this debug feature is being shipped disabled in 1.5, so bumping this to later. I really want to ship rename/codefixes/basic debugging in the next week or so.

@DanTup DanTup modified the milestones: 0.11, 0.10 Aug 31, 2016
@DanTup DanTup changed the title Switch run/debug to use integrated terminal Support targeting different terminals for running/debugging Sep 8, 2016
@DanTup
Copy link
Member Author

DanTup commented Sep 8, 2016

Insiders now supports targetting external terminals too. I think it might make sense to support all these options and let the user configure (and pick a good default).

@DanTup DanTup modified the milestones: 0.11, v1.0 Sep 8, 2016
@DanTup
Copy link
Member Author

DanTup commented Sep 18, 2016

If Code gives us a pid, we might be able to use SIGQUIT to get the port instead of hard-coding:

https://dart-lang.github.io/observatory/get-started.html

$ ps ax | grep dart
<pid> pts/61   Sl+    0:01 dart example.dart
$ kill -s SIGQUIT <pid>
Observatory listening on http://127.0.0.1:<port>

@devoncarew
Copy link
Contributor

The sigquit response gets written to stdout, so tough to get ahold of if you don't already have access to stdout (and if you do, scrapping for the Observatory listening on message is pretty reliable, and lets the port we bind to float).

@DanTup
Copy link
Member Author

DanTup commented Sep 18, 2016

The sigquit response gets written to stdout, so tough to get ahold of if you don't already have access to stdout

Ah, good point :( I'll have to have a play around and see what I can figure out when it's working. Been really busy last week or so so haven't made much progress. Hopefully will get more time later this week!

@DanTup
Copy link
Member Author

DanTup commented Sep 26, 2016

Another thought: even if we could get stdout, I don't think it's reasonable to spew stuff to the users stdout.

I think we'd be best randomly picking a port number and sending it (and either hoping it's not already bound or finding a way to check that won't leave it locked).

@DanTup DanTup added the in cli Relates to running Dart CLI scripts label Nov 15, 2018
@Rodsevich
Copy link

Please add this!! 🙏

@DanTup DanTup modified the milestones: Backlog, v3.4.0 Jul 31, 2019
@DanTup DanTup modified the milestones: v3.4.0, v3.5.0 Aug 26, 2019
@DanTup DanTup added the blocked on dart / flutter Requires a change in Dart or Flutter to progress label Sep 17, 2019
@DanTup DanTup modified the milestones: v3.5.0, On Deck Sep 17, 2019
@DanTup
Copy link
Member Author

DanTup commented Sep 17, 2019

I'd planned to try and get my workarounds working again, but there's a potential change in Dart that would significantly simplify this (removing the need to use hard-coded ports), so it makes sense to wait to see if that goes ahead before doing anything here.

dart-lang/sdk#38418

@DanTup
Copy link
Member Author

DanTup commented Oct 10, 2019

Another option that might help here, is the new Terminal API in Code:

https://code.visualstudio.com/updates/v1_39#_extension-terminal-api

This would allow us to run as we do today, but target the terminal window with a fake process - and when the user types into it, we can pass that to the real stdin of the process.

@DanTup DanTup modified the milestones: On Deck, v3.7.0 Oct 10, 2019
@DanTup DanTup removed the blocked on dart / flutter Requires a change in Dart or Flutter to progress label Oct 10, 2019
@DanTup DanTup modified the milestones: v3.7.0, On Deck Nov 14, 2019
@DanTup DanTup closed this as completed in 06f3bf1 Nov 20, 2019
@DanTup DanTup modified the milestones: On Deck, v3.7.0 Nov 20, 2019
@Thiha112
Copy link

I can not still satisfied because my terminal is exist running the code within 3s and I did not even notice what was the output. can someone explain this to me?

@DanTup
Copy link
Member Author

DanTup commented Jun 1, 2020

@Aung-Thiha112 Do you mean the output is disappearing? The Terminal should remain available after the application finishes - is that not what you see? If not, please file a new issue with details.

@kyrosle
Copy link

kyrosle commented Oct 25, 2023

hello, why my flutter project doesn't support setting "console": "terminal", in the launch.json? but the dart project allow that

➜  ~ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.11, on macOS 13.6 22G120 darwin-arm64, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.83.1)
[✓] VS Code (version 1.83.1)
[!] Proxy Configuration
    ! NO_PROXY is not set
[✓] Connected device (2 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.

@DanTup
Copy link
Member Author

DanTup commented Oct 25, 2023

@kyrosle it's not possible because of the way Flutter works. That setting is to tell VS Code to execute the script so you can use things like stdin.readline(). In Flutter, this isn't possible because a) the program may be running on another device where you can't access stdin and b) the debugger has to interact with the flutter tool over stdin/stdout (which it can't do if it's running in a terminal it has no access to).

Can you explain what it is you're trying to do?

@kyrosle
Copy link

kyrosle commented Oct 25, 2023

my project has lots of log, info, warn, debug and error, i used to writing code in vscode and running the program in jetbrain android studio, but recently i want to make all development in vscode, and then i found that the vscode debug consle is so hard to watch the log message. vscode debug console only support filter the log message...
i think i could using the intergate terminal instead of the debug console, cos of, the intergate terminal support the searching text, or i can watch the log message in the output window, btw, it is possible that similar with jb debug console by open a new window to show the flutter output?

@DanTup
Copy link
Member Author

DanTup commented Oct 25, 2023

Thanks for the info. Unfortunately I don't know a great way to do this - it sounds like it might be worth filing a VS Code issue for being able to Find (not filter) in the Debug Console.

As a workaround, you could use flutter run to run your application in the terminal, but you would lose debug functionality. You could get some of this back by then running Debug: Attach to Flutter to attach the debugger to the instance you're running from the terminal, but it's a little clunky.

@kyrosle
Copy link

kyrosle commented Oct 31, 2023

is any possible to achive it by this way? microsoft/vscode#4338 (comment)

@DanTup
Copy link
Member Author

DanTup commented Oct 31, 2023

@kyrosle yes, that's an existing feature request for Find in the Debug Console. I thought there was already an issue but hadn't been able to find it when I wrote the comment above. Please add your 👍 to that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in cli Relates to running Dart CLI scripts in debugger Relates to the debug adapter or process of launching a debug session is enhancement
Projects
None yet
Development

No branches or pull requests

5 participants