[feature] Offer to start the emulator

If we are not connected to the Fuchsia emulator, we now offer to start
the emulator instead of producing an error message. Also, once we start
the emulator, refresh the target list so that the extension will
actually connect to the emulator.

Change-Id: I59cff96ea075df088cc1fb6c84031d4a9507577b
Reviewed-on: https://fuchsia-review.googlesource.com/c/vscode-plugins/+/1029732
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Jacob Rutherford <jruthe@google.com>
diff --git a/src/ffx.ts b/src/ffx.ts
index b202562..87f2662 100644
--- a/src/ffx.ts
+++ b/src/ffx.ts
@@ -180,8 +180,13 @@
    * Start the emulator.
    * @returns stdout of the command, or error contains the stderr.
    */
-  public startEmulator(): Promise<string> {
-    return this.runFfx(['emu', 'start'], defaultTimeoutMillis);
+  public async startEmulator(): Promise<string> {
+    let result = await this.runFfx(['emu', 'start'], defaultTimeoutMillis);
+    // Refresh the target list now that the emulator has started, which will
+    // cause us to connect to the emulator if the user has selected that
+    // device.
+    await this.getTargetList();
+    return result;
   }
 
   /**
diff --git a/src/target_status_bar_item.ts b/src/target_status_bar_item.ts
index 79cc32c..9737310 100644
--- a/src/target_status_bar_item.ts
+++ b/src/target_status_bar_item.ts
@@ -71,7 +71,13 @@
     for (let key in targetList) {
       let device = targetList[key];
       // Ignore devices that are not connected.
-      if (!device.connected) { continue; }
+      if (!device.connected) {
+        if (device.nodeName === 'fuchsia-emulator') {
+          items.push(new TargetPickAction('Start Fuchsia emulator', device,
+            'fuchsia.emu.start'));
+        }
+        continue;
+      }
 
       if (device.isDefault) {
         // Add items to front of list.