-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vscode): add config for icons/icon colors
- Loading branch information
Showing
5 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,46 @@ | ||
import { ViewProviders } from './view/views'; | ||
import { TSExplorer } from "./config"; | ||
import * as vscode from 'vscode' | ||
import { TypeTreeProvider } from './view/typeTreeView'; | ||
|
||
export function registerCommands(context: vscode.ExtensionContext, ViewProviders: ViewProviders) { | ||
context.subscriptions.push( | ||
vscode.commands.registerCommand('typescript-explorer.toggleExpandedHover', TSExplorer.Config.toggleExpandedHover) | ||
type CommandHandler = (...args: any[]) => void|Promise<void> | ||
type CommandInfo = [id: string, handler: CommandHandler] | ||
|
||
const normalCommands: CommandInfo[] = [ | ||
["typescript-explorer.toggleExpandedHover", TSExplorer.Config.toggleExpandedHover], | ||
] | ||
|
||
const typeTreeViewCommands = (typeTreeProvider: TypeTreeProvider): CommandInfo[] => ([ | ||
["typescript-explorer.typeTree.view.icons.enabled.toggle", TSExplorer.Config.TypeTreeView.toggleIconsEnabled], | ||
["typescript-explorer.typeTree.view.icons.colors.enabled.toggle", TSExplorer.Config.TypeTreeView.toggleIconColorsEnabled] | ||
] as RefreshableCommandInfo[]).map(t => wrapRefresh(t, typeTreeProvider)) | ||
|
||
export function registerCommands(context: vscode.ExtensionContext, { typeTreeProvider }: ViewProviders) { | ||
const commands = [ | ||
...normalCommands, | ||
...typeTreeViewCommands(typeTreeProvider) | ||
] | ||
|
||
commands.forEach(c => registerCommand(c, context)) | ||
} | ||
|
||
type RefreshableCommandInfo = CommandInfo | [...CommandInfo, boolean] | ||
|
||
function wrapRefresh(command: RefreshableCommandInfo, refreshable: {refresh(): void}): CommandInfo { | ||
const [id, handler, refresh=true] = command | ||
|
||
if(!refresh) { | ||
return [id, handler] | ||
} | ||
|
||
return [id, async () => { | ||
await handler() | ||
refreshable.refresh() | ||
}] | ||
} | ||
|
||
function registerCommand([id, handler]: CommandInfo, context: vscode.ExtensionContext) { | ||
context.subscriptions.push( | ||
vscode.commands.registerCommand(id, handler) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters