Skip to content

Commit

Permalink
forループの filter, map 化
Browse files Browse the repository at this point in the history
  • Loading branch information
wraith13 committed Mar 2, 2017
1 parent 25e4a7e commit 78a08e6
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down

0 comments on commit 78a08e6

Please sign in to comment.