2018-04-30 09:55:47 +02:00
|
|
|
import {
|
|
|
|
workspace as Workspace,
|
|
|
|
commands as Commands
|
|
|
|
} from 'vscode';
|
2018-04-20 20:07:36 +02:00
|
|
|
|
2018-05-18 13:47:22 +02:00
|
|
|
import * as ThemeCommands from './commands';
|
|
|
|
import {isAutoApplyEnable} from './helpers/settings';
|
|
|
|
import {onChangeConfiguration} from './helpers/configuration-change';
|
2018-06-21 23:02:57 +02:00
|
|
|
import {infoMessage, changelogMessage} from './helpers/messages';
|
2018-05-18 13:47:22 +02:00
|
|
|
import shouldShowChangelog from './helpers/should-show-changelog';
|
2018-04-21 18:17:20 +02:00
|
|
|
|
2018-06-21 23:02:57 +02:00
|
|
|
export async function activate() {
|
2018-04-30 09:55:47 +02:00
|
|
|
const config = Workspace.getConfiguration();
|
2018-04-20 20:07:36 +02:00
|
|
|
|
2018-04-30 09:55:47 +02:00
|
|
|
// Listen on set theme: when the theme is Material Theme, just adjust icon and accent.
|
2018-05-18 13:47:22 +02:00
|
|
|
Workspace.onDidChangeConfiguration(onChangeConfiguration);
|
2018-04-21 18:17:20 +02:00
|
|
|
|
2018-04-30 09:55:47 +02:00
|
|
|
// Delete old configuration, must remove with next major release
|
|
|
|
if (config.has('materialTheme.cache.workbench')) {
|
|
|
|
config.update('materialTheme.cache.workbench', undefined, true);
|
|
|
|
}
|
|
|
|
|
2018-04-20 20:07:36 +02:00
|
|
|
if (shouldShowChangelog()) {
|
2018-06-21 23:02:57 +02:00
|
|
|
const show = await changelogMessage();
|
|
|
|
if (show) {
|
|
|
|
ThemeCommands.showChangelog();
|
|
|
|
}
|
2018-04-20 20:07:36 +02:00
|
|
|
}
|
|
|
|
|
2018-04-30 09:55:47 +02:00
|
|
|
// Registering commands
|
2018-05-18 13:47:22 +02:00
|
|
|
Commands.registerCommand('materialTheme.setAccent', async () => {
|
|
|
|
const wasSet = await ThemeCommands.accentsSetter();
|
|
|
|
|
|
|
|
if (wasSet) {
|
|
|
|
return isAutoApplyEnable() ? ThemeCommands.fixIcons() : infoMessage();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Commands.registerCommand('materialTheme.fixIcons', () => ThemeCommands.fixIcons());
|
|
|
|
Commands.registerCommand('materialTheme.toggleApplyIcons', () => ThemeCommands.toggleApplyIcons());
|
|
|
|
Commands.registerCommand('materialTheme.showChangelog', () => ThemeCommands.showChangelog());
|
2018-04-20 20:07:36 +02:00
|
|
|
}
|