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

Add completer to ensure rStart is passed after pty init #458

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/r/start.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

library;

import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -99,7 +100,19 @@ void rStart(BuildContext context, WidgetRef ref) async {
// startup. Seems to have a slight delay on Linux with a all black
// screen. Let's see what it does on Windows.

await Future(() {
await Future(() async {

// Create a Completer to ensure pty is ready before writing to it.
Completer<void> ptyReadyCompleter = Completer<void>();

// Mark the pty as ready after it has been initialized.
ref.read(ptyProvider).exitCode.then((_) {
ptyReadyCompleter.complete();
});

// extra delay
const duration = Duration(seconds: 1);
await Future.delayed(duration);
// Add the code to the script.

updateScript(ref, code);
Expand Down