From b9e36ac926885227a23068ee36455ee0c2a292fa Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Wed, 27 Jun 2018 14:21:23 +0200 Subject: [PATCH] Show errors from command line (Microsoft/vscode#52902) --- quickinput-sample/src/quickOpen.ts | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/quickinput-sample/src/quickOpen.ts b/quickinput-sample/src/quickOpen.ts index c6f8fa29..9878a2be 100644 --- a/quickinput-sample/src/quickOpen.ts +++ b/quickinput-sample/src/quickOpen.ts @@ -34,11 +34,23 @@ class FileItem implements QuickPickItem { } } +class MessageItem implements QuickPickItem { + + label: string; + description = ''; + detail: string; + + constructor(public base: Uri, public message: string) { + this.label = message.replace(/\r?\n/g, ' '); + this.detail = base.fsPath; + } +} + async function pickFile() { const disposables: Disposable[] = []; try { return await new Promise((resolve, reject) => { - const input = window.createQuickPick(); + const input = window.createQuickPick(); input.placeholder = 'Type to search for files'; let rgs: cp.ChildProcess[] = []; disposables.push( @@ -64,6 +76,11 @@ async function pickFile() { .map(relative => new FileItem(Uri.file(cwd), Uri.file(path.join(cwd, relative)))) ); } + if (err && !(err).killed && (err).code !== 1 && err.message) { + input.items = input.items.concat([ + new MessageItem(Uri.file(cwd), err.message) + ]); + } rgs.splice(i, 1); if (!rgs.length) { input.busy = false; @@ -74,8 +91,11 @@ async function pickFile() { }); }), input.onDidChangeSelection(items => { - resolve(items[0].uri); - input.hide(); + const item = items[0]; + if (item instanceof FileItem) { + resolve(item.uri); + input.hide(); + } }), input.onDidHide(() => { rgs.forEach(rg => rg.kill());