提交 8ea295e6 编写于 作者: S Sandeep Somavarapu

Fix #91603

- Use list resource navigator to open extensions
上级 90aeac83
......@@ -83,7 +83,9 @@ class NavBar extends Disposable {
private _onChange = this._register(new Emitter<{ id: string | null, focus: boolean }>());
get onChange(): Event<{ id: string | null, focus: boolean }> { return this._onChange.event; }
private currentId: string | null = null;
private _currentId: string | null = null;
get currentId(): string | null { return this._currentId; }
private actions: Action[];
private actionbar: ActionBar;
......@@ -113,11 +115,11 @@ class NavBar extends Disposable {
}
update(): void {
this._update(this.currentId);
this._update(this._currentId);
}
_update(id: string | null = this.currentId, focus?: boolean): Promise<void> {
this.currentId = id;
_update(id: string | null = this._currentId, focus?: boolean): Promise<void> {
this._currentId = id;
this._onChange.fire({ id, focus: !!focus });
this.actions.forEach(a => a.checked = a.id === id);
return Promise.resolve(undefined);
......@@ -308,12 +310,12 @@ export class ExtensionEditor extends BaseEditor {
async setInput(input: ExtensionsInput, options: EditorOptions | undefined, token: CancellationToken): Promise<void> {
if (this.template) {
await this.updateTemplate(input, this.template);
await this.updateTemplate(input, this.template, !!options?.preserveFocus);
}
return super.setInput(input, options, token);
}
private async updateTemplate(input: ExtensionsInput, template: IExtensionEditorTemplate): Promise<void> {
private async updateTemplate(input: ExtensionsInput, template: IExtensionEditorTemplate, preserveFocus: boolean): Promise<void> {
const runningExtensions = await this.extensionService.getExtensions();
const colorThemes = await this.workbenchThemeService.getColorThemes();
const fileIconThemes = await this.workbenchThemeService.getFileIconThemes();
......@@ -423,31 +425,34 @@ export class ExtensionEditor extends BaseEditor {
template.content.innerHTML = ''; // Clear content before setting navbar actions.
template.navbar.clear();
template.navbar.onChange(e => this.onNavbarChange(extension, e, template), this, this.transientDisposables);
if (extension.hasReadme()) {
template.navbar.push(NavbarSection.Readme, localize('details', "Details"), localize('detailstooltip', "Extension details, rendered from the extension's 'README.md' file"));
}
this.extensionManifest.get()
.promise
.then(manifest => {
if (manifest) {
combinedInstallAction.manifest = manifest;
}
if (extension.extensionPack.length) {
template.navbar.push(NavbarSection.ExtensionPack, localize('extensionPack', "Extension Pack"), localize('extensionsPack', "Set of extensions that can be installed together"));
}
if (manifest && manifest.contributes) {
template.navbar.push(NavbarSection.Contributions, localize('contributions', "Feature Contributions"), localize('contributionstooltip', "Lists contributions to VS Code by this extension"));
}
if (extension.hasChangelog()) {
template.navbar.push(NavbarSection.Changelog, localize('changelog', "Changelog"), localize('changelogtooltip', "Extension update history, rendered from the extension's 'CHANGELOG.md' file"));
}
if (extension.dependencies.length) {
template.navbar.push(NavbarSection.Dependencies, localize('dependencies', "Dependencies"), localize('dependenciestooltip', "Lists extensions this extension depends on"));
}
this.editorLoadComplete = true;
});
const manifest = await this.extensionManifest.get().promise;
if (manifest) {
combinedInstallAction.manifest = manifest;
}
if (extension.extensionPack.length) {
template.navbar.push(NavbarSection.ExtensionPack, localize('extensionPack', "Extension Pack"), localize('extensionsPack', "Set of extensions that can be installed together"));
}
if (manifest && manifest.contributes) {
template.navbar.push(NavbarSection.Contributions, localize('contributions', "Feature Contributions"), localize('contributionstooltip', "Lists contributions to VS Code by this extension"));
}
if (extension.hasChangelog()) {
template.navbar.push(NavbarSection.Changelog, localize('changelog', "Changelog"), localize('changelogtooltip', "Extension update history, rendered from the extension's 'CHANGELOG.md' file"));
}
if (extension.dependencies.length) {
template.navbar.push(NavbarSection.Dependencies, localize('dependencies', "Dependencies"), localize('dependenciestooltip', "Lists extensions this extension depends on"));
}
if (template.navbar.currentId) {
this.onNavbarChange(extension, { id: template.navbar.currentId, focus: !preserveFocus }, template);
}
template.navbar.onChange(e => this.onNavbarChange(extension, e, template), this, this.transientDisposables);
this.editorLoadComplete = true;
}
private setSubText(extension: IExtension, reloadAction: ReloadAction, template: IExtensionEditorTemplate): void {
......
......@@ -169,7 +169,7 @@ class OpenExtensionAction extends Action {
run(sideByside: boolean): Promise<any> {
if (this._extensionData) {
return this.extensionsWorkdbenchService.open(this._extensionData.extension, sideByside);
return this.extensionsWorkdbenchService.open(this._extensionData.extension, { sideByside });
}
return Promise.resolve();
}
......@@ -218,7 +218,7 @@ export class ExtensionsTree extends WorkbenchAsyncDataTree<IExtensionData, IExte
this.disposables.add(this.onDidChangeSelection(event => {
if (event.browserEvent && event.browserEvent instanceof KeyboardEvent) {
extensionsWorkdbenchService.open(event.elements[0].extension, false);
extensionsWorkdbenchService.open(event.elements[0].extension, { sideByside: false });
}
}));
}
......
......@@ -29,7 +29,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { InstallWorkspaceRecommendedExtensionsAction, ConfigureWorkspaceFolderRecommendedExtensionsAction, ManageExtensionAction, InstallLocalExtensionsInRemoteAction, getContextMenuActions } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
import { WorkbenchPagedList } from 'vs/platform/list/browser/listService';
import { WorkbenchPagedList, ResourceNavigator } from 'vs/platform/list/browser/listService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { ViewPane, IViewPaneOptions } from 'vs/workbench/browser/parts/views/viewPaneContainer';
......@@ -146,14 +146,14 @@ export class ExtensionsListView extends ViewPane {
}
});
this._register(this.list.onContextMenu(e => this.onContextMenu(e), this));
this._register(this.list.onFocusChange(e => extensionsViewState.onFocusChange(coalesce(e.elements)), this));
this._register(this.list.onDidChangeFocus(e => extensionsViewState.onFocusChange(coalesce(e.elements)), this));
this._register(this.list);
this._register(extensionsViewState);
this._register(Event.chain(this.list.onOpen)
.map(e => e.elements[0])
.filter(e => !!e)
.on(this.openExtension, this));
const resourceNavigator = this._register(ResourceNavigator.createListResourceNavigator(this.list, { openOnFocus: false, openOnSelection: true, openOnSingleClick: true }));
this._register(Event.debounce(Event.filter(resourceNavigator.onDidOpenResource, e => e.element !== null), (last, event) => event, 75, true)(options => {
this.openExtension(this.list!.model.get(options.element!), { sideByside: options.sideBySide, ...options.editorOptions });
}));
this._register(Event.chain(this.list.onPin)
.map(e => e.elements[0])
......@@ -750,9 +750,9 @@ export class ExtensionsListView extends ViewPane {
}
}
private openExtension(extension: IExtension): void {
private openExtension(extension: IExtension, options: { sideByside?: boolean, preserveFocus?: boolean, pinned?: boolean }): void {
extension = this.extensionsWorkbenchService.local.filter(e => areSameExtensions(e.identifier, extension.identifier))[0] || extension;
this.extensionsWorkbenchService.open(extension).then(undefined, err => this.onError(err));
this.extensionsWorkbenchService.open(extension, options).then(undefined, err => this.onError(err));
}
private pin(): void {
......
......@@ -630,8 +630,8 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
return text.substr(0, 350);
}
open(extension: IExtension, sideByside: boolean = false): Promise<any> {
return Promise.resolve(this.editorService.openEditor(this.instantiationService.createInstance(ExtensionsInput, extension), undefined, sideByside ? SIDE_GROUP : ACTIVE_GROUP));
open(extension: IExtension, { sideByside, preserveFocus, pinned }: { sideByside?: boolean, preserveFocus?: boolean, pinned?: boolean } = { sideByside: false, preserveFocus: false, pinned: false }): Promise<any> {
return Promise.resolve(this.editorService.openEditor(this.instantiationService.createInstance(ExtensionsInput, extension), { preserveFocus, pinned }, sideByside ? SIDE_GROUP : ACTIVE_GROUP));
}
private getPrimaryExtension(extensions: IExtension[]): IExtension {
......
......@@ -86,7 +86,7 @@ export interface IExtensionsWorkbenchService {
installVersion(extension: IExtension, version: string): Promise<IExtension>;
reinstall(extension: IExtension): Promise<IExtension>;
setEnablement(extensions: IExtension | IExtension[], enablementState: EnablementState): Promise<void>;
open(extension: IExtension, sideByside?: boolean): Promise<any>;
open(extension: IExtension, options?: { sideByside?: boolean, preserveFocus?: boolean, pinned?: boolean }): Promise<any>;
checkForUpdates(): Promise<void>;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册