提交 7cc71d65 编写于 作者: A Alex Ross

Fix broken remote explorer drop down

Partial fix for https://github.com/microsoft/vscode/issues/112750
上级 48c2ad64
......@@ -31,36 +31,42 @@ export class SwitchRemoteViewItem extends SelectActionViewItem {
private readonly optionsItems: IRemoteSelectItem[],
@IThemeService themeService: IThemeService,
@IContextViewService contextViewService: IContextViewService,
@IRemoteExplorerService remoteExplorerService: IRemoteExplorerService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IRemoteExplorerService private remoteExplorerService: IRemoteExplorerService,
@IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService,
@IStorageService private readonly storageService: IStorageService
) {
super(null, action, optionsItems, 0, contextViewService, { ariaLabel: nls.localize('remotes', 'Switch Remote') });
this._register(attachSelectBoxStyler(this.selectBox, themeService));
this.setSelectionForConnection(optionsItems, environmentService, remoteExplorerService);
}
private setSelectionForConnection(optionsItems: IRemoteSelectItem[], environmentService: IWorkbenchEnvironmentService, remoteExplorerService: IRemoteExplorerService) {
public setSelectionForConnection(): boolean {
let isSetForConnection = false;
if (this.optionsItems.length > 0) {
let index = 0;
const remoteAuthority = environmentService.remoteAuthority;
const remoteAuthority = this.environmentService.remoteAuthority;
isSetForConnection = true;
const explorerType: string[] | undefined = remoteAuthority ? [remoteAuthority.split('+')[0]] :
this.storageService.get(REMOTE_EXPLORER_TYPE_KEY, StorageScope.WORKSPACE)?.split(',') ?? this.storageService.get(REMOTE_EXPLORER_TYPE_KEY, StorageScope.GLOBAL)?.split(',');
if (explorerType !== undefined) {
index = this.getOptionIndexForExplorerType(optionsItems, explorerType);
index = this.getOptionIndexForExplorerType(explorerType);
}
this.select(index);
remoteExplorerService.targetType = optionsItems[index].authority;
this.remoteExplorerService.targetType = this.optionsItems[index].authority;
}
return isSetForConnection;
}
public setSelection() {
const index = this.getOptionIndexForExplorerType(this.remoteExplorerService.targetType);
this.select(index);
}
private getOptionIndexForExplorerType(optionsItems: IRemoteSelectItem[], explorerType: string[]): number {
private getOptionIndexForExplorerType(explorerType: string[]): number {
let index = 0;
for (let optionIterator = 0; (optionIterator < this.optionsItems.length) && (index === 0); optionIterator++) {
for (let authorityIterator = 0; authorityIterator < optionsItems[optionIterator].authority.length; authorityIterator++) {
for (let authorityIterator = 0; authorityIterator < this.optionsItems[optionIterator].authority.length; authorityIterator++) {
for (let i = 0; i < explorerType.length; i++) {
if (optionsItems[optionIterator].authority[authorityIterator] === explorerType[i]) {
if (this.optionsItems[optionIterator].authority[authorityIterator] === explorerType[i]) {
index = optionIterator;
break;
}
......
......@@ -460,6 +460,7 @@ class HelpPanelDescriptor implements IViewDescriptor {
export class RemoteViewPaneContainer extends FilterViewPaneContainer implements IViewModel {
private helpPanelDescriptor = new HelpPanelDescriptor(this);
helpInformation: HelpInformation[] = [];
private hasSetSwitchForConnection: boolean = false;
constructor(
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
......@@ -520,7 +521,14 @@ export class RemoteViewPaneContainer extends FilterViewPaneContainer implements
public getActionViewItem(action: Action): IActionViewItem | undefined {
if (action.id === SwitchRemoteAction.ID) {
return this.instantiationService.createInstance(SwitchRemoteViewItem, action, SwitchRemoteViewItem.createOptionItems(Registry.as<IViewsRegistry>(Extensions.ViewsRegistry).getViews(this.viewContainer), this.contextKeyService));
const optionItems = SwitchRemoteViewItem.createOptionItems(Registry.as<IViewsRegistry>(Extensions.ViewsRegistry).getViews(this.viewContainer), this.contextKeyService);
const item = this.instantiationService.createInstance(SwitchRemoteViewItem, action, optionItems);
if (!this.hasSetSwitchForConnection) {
this.hasSetSwitchForConnection = item.setSelectionForConnection();
} else {
item.setSelection();
}
return item;
}
return super.getActionViewItem(action);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册