From b2a37b8fc3e273dd71e1e3558c58be8002aa3789 Mon Sep 17 00:00:00 2001
From: Shin'ya Ueoka <ueokande@i-beam.org>
Date: Thu, 26 Mar 2020 22:17:00 +0900
Subject: Query completions on open command by a completion source

---
 src/console/components/Console.tsx | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

(limited to 'src/console/components/Console.tsx')

diff --git a/src/console/components/Console.tsx b/src/console/components/Console.tsx
index 0a102a0..7be073e 100644
--- a/src/console/components/Console.tsx
+++ b/src/console/components/Console.tsx
@@ -7,6 +7,7 @@ import Message from './console/Message';
 import * as consoleActions from '../../console/actions/console';
 import { State as AppState } from '../reducers';
 import CommandLineParser, { InputPhase } from "../commandline/CommandLineParser";
+import { Command } from "../../shared/Command";
 
 const COMPLETION_MAX_ITEMS = 33;
 
@@ -163,7 +164,16 @@ class Console extends React.Component<Props> {
     if (phase === InputPhase.OnCommand) {
       return this.props.dispatch(consoleActions.getCommandCompletions(text));
     } else {
-      this.props.dispatch(consoleActions.getCompletions(text));
+      const cmd = this.commandLineParser.parse(text);
+      switch (cmd.command) {
+      case Command.Open:
+      case Command.TabOpen:
+      case Command.WindowOpen:
+        this.props.dispatch(consoleActions.getOpenCompletions(this.props.completionTypes, text, cmd.command, cmd.args));
+        break;
+      default:
+        this.props.dispatch(consoleActions.getCompletions(text));
+      }
     }
   }
 }
-- 
cgit v1.2.3

