Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
Empty Workspace fixes (#2353)
Browse files Browse the repository at this point in the history
* Remove test file commands when not in a workspace.

* Also fix Ctrl-P menu when no workspace is open.

* Fix lint.
  • Loading branch information
CrossR authored Jun 25, 2018
1 parent 7b15dce commit d1a818e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
6 changes: 5 additions & 1 deletion browser/src/Services/QuickOpen/QuickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 20 additions & 0 deletions browser/src/Services/QuickOpen/QuickOpenItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions browser/src/Services/Workspace/WorkspaceCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d1a818e

Please sign in to comment.