From d1a818e4967618fd17a57d071c92d3833c4493b2 Mon Sep 17 00:00:00 2001 From: Ryan C Date: Mon, 25 Jun 2018 18:08:57 +0100 Subject: [PATCH] Empty Workspace fixes (#2353) * Remove test file commands when not in a workspace. * Also fix Ctrl-P menu when no workspace is open. * Fix lint. --- browser/src/Services/QuickOpen/QuickOpen.ts | 6 +++++- .../src/Services/QuickOpen/QuickOpenItem.ts | 20 +++++++++++++++++++ .../Services/Workspace/WorkspaceCommands.ts | 5 +++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/browser/src/Services/QuickOpen/QuickOpen.ts b/browser/src/Services/QuickOpen/QuickOpen.ts index 6b2d5e4fe5..94fcd3d609 100644 --- a/browser/src/Services/QuickOpen/QuickOpen.ts +++ b/browser/src/Services/QuickOpen/QuickOpen.ts @@ -290,9 +290,13 @@ export class QuickOpen { const file = path.basename(f) const folder = path.dirname(f) const pinned = this._seenItems.indexOf(f) >= 0 + const icon = + QuickOpenItem.convertIconToType(qitem.icon) !== QuickOpenType.file + ? qitem.icon + : (getFileIcon(file) as any) return { - icon: getFileIcon(file) as any, + icon, label: file, detail: folder, pinned, diff --git a/browser/src/Services/QuickOpen/QuickOpenItem.ts b/browser/src/Services/QuickOpen/QuickOpenItem.ts index 6a57b23920..795f46e9f8 100644 --- a/browser/src/Services/QuickOpen/QuickOpenItem.ts +++ b/browser/src/Services/QuickOpen/QuickOpenItem.ts @@ -8,6 +8,7 @@ export enum QuickOpenType { folder, folderHelp, bufferLine, + unknown, } // Wrapper around quick open items, this not only allows us to show multiple icons @@ -33,6 +34,25 @@ export class QuickOpenItem { } } + public static convertIconToType(icon: string): QuickOpenType { + switch (icon) { + case "star-o": + return QuickOpenType.bookmark + case "info": + return QuickOpenType.bookmarkHelp + case "file-text-o": + return QuickOpenType.file + case "folder-o": + return QuickOpenType.folder + case "folder-open-o": + return QuickOpenType.folderHelp + case "angle-right": + return QuickOpenType.bufferLine + default: + return QuickOpenType.unknown + } + } + // Each has an item, and an icon private _item: string private _icon: string diff --git a/browser/src/Services/Workspace/WorkspaceCommands.ts b/browser/src/Services/Workspace/WorkspaceCommands.ts index 69c0a1a203..01a2708efc 100644 --- a/browser/src/Services/Workspace/WorkspaceCommands.ts +++ b/browser/src/Services/Workspace/WorkspaceCommands.ts @@ -69,6 +69,11 @@ export const activateCommands = ( return null } + // If we have no active workspace, we don't know where test files live. + if (!workspace.activeWorkspace) { + return null + } + const currentEditor = editorManager.activeEditor if (!currentEditor || !currentEditor.activeBuffer) {