forked from openkylin/kylin-code
Fixed 项目创建后,帮助菜单缺少插件依赖管理器和离线插件管理器菜单项
This commit is contained in:
parent
e98641595c
commit
f5ee416cc7
|
@ -14,7 +14,7 @@ import { Context as SuggestContext } from 'vs/editor/contrib/suggest/browser/sug
|
|||
import * as nls from 'vs/nls';
|
||||
import { Action2, MenuId, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions';
|
||||
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { InputFocusedContext, IsMacNativeContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
@ -60,9 +60,6 @@ const SETTINGS_EDITOR_COMMAND_FILTER_UNTRUSTED = 'settings.filterUntrusted';
|
|||
|
||||
const SETTINGS_COMMAND_OPEN_SETTINGS = 'workbench.action.openSettings';
|
||||
|
||||
const HasInstalledExtDependencyExtensionContext = new RawContextKey<boolean>('hasExtDependency', false); //by wpl
|
||||
const HasInstalledOfflineExtManagerExtensionContext = new RawContextKey<boolean>('hasOfflineExtManager', false); //by wpl
|
||||
|
||||
|
||||
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
|
||||
EditorPaneDescriptor.create(
|
||||
|
@ -141,16 +138,12 @@ function sanitizeOpenSettingsArgs(args: any): IOpenSettingsActionOptions {
|
|||
|
||||
class PreferencesActionsContribution extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
private HasInstalledExtDependencyExtensionContextKey: IContextKey<boolean>;
|
||||
private HasInstalledOfflineExtManagerExtensionContextKey: IContextKey<boolean>;
|
||||
|
||||
constructor(
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@IPreferencesService private readonly preferencesService: IPreferencesService,
|
||||
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
|
||||
@ILabelService private readonly labelService: ILabelService,
|
||||
@IExtensionService private readonly extensionService: IExtensionService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
) {
|
||||
super();
|
||||
|
||||
|
@ -161,21 +154,6 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
|
|||
this._register(workspaceContextService.onDidChangeWorkbenchState(() => this.updatePreferencesEditorMenuItem()));
|
||||
this._register(workspaceContextService.onDidChangeWorkspaceFolders(() => this.updatePreferencesEditorMenuItemForWorkspaceFolders()));
|
||||
|
||||
this.HasInstalledExtDependencyExtensionContextKey = HasInstalledExtDependencyExtensionContext.bindTo(contextKeyService);
|
||||
this.HasInstalledOfflineExtManagerExtensionContextKey = HasInstalledOfflineExtManagerExtensionContext.bindTo(contextKeyService);
|
||||
this.checkallextension();
|
||||
}
|
||||
|
||||
//check extension
|
||||
private async checkallextension() {
|
||||
const runningExtensions = await this.extensionService.getExtensions();
|
||||
for (let extension of runningExtensions) {
|
||||
if (extension.identifier.value === 'KylinIDETeam.extension-dependency') {
|
||||
this.HasInstalledExtDependencyExtensionContextKey.set(true);
|
||||
} else if (extension.identifier.value === 'KylinIDETeam.offline-extensions-manager') {
|
||||
this.HasInstalledOfflineExtManagerExtensionContextKey.set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private registerSettingsActions() {
|
||||
|
|
|
@ -15,23 +15,34 @@ import { localize } from 'vs/nls';
|
|||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
const HasInstalledExtDependencyExtensionContext = new RawContextKey<boolean>('hasExtDependency', false);
|
||||
const HasInstalledOfflineExtManagerExtensionContext = new RawContextKey<boolean>('hasOfflineExtManager', false);
|
||||
export class CachedExtensionScanner {
|
||||
|
||||
public readonly scannedExtensions: Promise<IExtensionDescription[]>;
|
||||
private _scannedExtensionsResolve!: (result: IExtensionDescription[]) => void;
|
||||
private _scannedExtensionsReject!: (err: any) => void;
|
||||
|
||||
private HasInstalledExtDependencyExtensionContextKey: IContextKey<boolean>;
|
||||
private HasInstalledOfflineExtManagerExtensionContextKey: IContextKey<boolean>;
|
||||
|
||||
constructor(
|
||||
@INotificationService private readonly _notificationService: INotificationService,
|
||||
@IHostService private readonly _hostService: IHostService,
|
||||
@IExtensionsScannerService private readonly _extensionsScannerService: IExtensionsScannerService,
|
||||
@ILogService private readonly _logService: ILogService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
) {
|
||||
this.scannedExtensions = new Promise<IExtensionDescription[]>((resolve, reject) => {
|
||||
this._scannedExtensionsResolve = resolve;
|
||||
this._scannedExtensionsReject = reject;
|
||||
});
|
||||
|
||||
this.HasInstalledExtDependencyExtensionContextKey = HasInstalledExtDependencyExtensionContext.bindTo(contextKeyService);
|
||||
this.HasInstalledOfflineExtManagerExtensionContextKey = HasInstalledOfflineExtManagerExtensionContext.bindTo(contextKeyService);
|
||||
|
||||
}
|
||||
|
||||
public async scanSingleExtension(extensionPath: string, isBuiltin: boolean): Promise<IExtensionDescription | null> {
|
||||
|
@ -43,6 +54,13 @@ export class CachedExtensionScanner {
|
|||
try {
|
||||
const { system, user, development } = await this._scanInstalledExtensions();
|
||||
const r = dedupExtensions(system, user, development, this._logService);
|
||||
for (let extension of r) {
|
||||
if (extension.identifier.value === 'KylinIDETeam.extension-dependency') {
|
||||
this.HasInstalledExtDependencyExtensionContextKey.set(true);
|
||||
} else if (extension.identifier.value === 'KylinIDETeam.offline-extensions-manager') {
|
||||
this.HasInstalledOfflineExtManagerExtensionContextKey.set(true);
|
||||
}
|
||||
}
|
||||
this._scannedExtensionsResolve(r);
|
||||
} catch (err) {
|
||||
this._scannedExtensionsReject(err);
|
||||
|
|
Loading…
Reference in New Issue