From 78a08e6061a9ebcc31471f0a2207f3727c9262d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=93=E5=8C=96=E5=B8=AB?= Date: Thu, 2 Mar 2017 13:28:58 +0900 Subject: [PATCH] =?UTF-8?q?for=E3=83=AB=E3=83=BC=E3=83=97=E3=81=AE=20filte?= =?UTF-8?q?r,=20map=20=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extension.ts | 50 ++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 188b075..3203079 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -929,47 +929,43 @@ module WandboxVSCode var document = WorkSpace.getActiveDocument(); var setting = fileSetting[document.fileName] || {}; var stdin : string = setting['stdin']; - let fileList : vscode.QuickPickItem[] = []; let noStdIn : vscode.QuickPickItem = { label: emoji(!stdin ? "checkedRadio": "uncheckedRadio") +"no stdin", description: null, detail: null }; - fileList.push(noStdIn); - WorkSpace.getTextFiles() - .forEach - ( - fileName => fileList.push - ( - { - label: emoji(stdin === fileName ? "checkedRadio": "uncheckedRadio") +stripDirectory(fileName), - description: fileName, - detail: document.fileName === fileName ? "this file itself": null - } - ) - ); - if (stdin && !fileList.find(item => stdin === item.description)) - { - fileList.push - ( - { - label: emoji("checkedRadio") +stripDirectory(stdin), - description: stdin, - detail: `${emoji("error")}Not found file ( If opened, show this file once. And keep to open it.)` - } - ); - } let newUntitledDocument : vscode.QuickPickItem = { label: `${emoji("new")}new untitled document`, description: null, detail: null }; - fileList.push(newUntitledDocument); + let workspaceTextFiles = WorkSpace.getTextFiles(); let select = await vscode.window.showQuickPick ( - fileList, + [].concat + ( + noStdIn, + workspaceTextFiles.map + ( + fileName => pass_through = + { + label: emoji(stdin === fileName ? "checkedRadio": "uncheckedRadio") +stripDirectory(fileName), + description: fileName, + detail: document.fileName === fileName ? "this file itself": null + } + ), + (stdin && !workspaceTextFiles.find(fileName => stdin === fileName)) ? + { + label: emoji("checkedRadio") +stripDirectory(stdin), + description: stdin, + detail: `${emoji("error")}Not found file ( If opened, show this file once. And keep to open it.)` + }: + null, + newUntitledDocument + ) + .filter(i => i), { placeHolder: "Select a file as a stdin", }