提交 6e3c4680 编写于 作者: B Benjamin Pasero

fix #14020

上级 8531bff9
...@@ -39,6 +39,8 @@ export class ExplorerViewlet extends Viewlet { ...@@ -39,6 +39,8 @@ export class ExplorerViewlet extends Viewlet {
private explorerView: ExplorerView; private explorerView: ExplorerView;
private openEditorsView: OpenEditorsView; private openEditorsView: OpenEditorsView;
private emptyView: EmptyView;
private openEditorsVisible: boolean; private openEditorsVisible: boolean;
private lastFocusedView: ExplorerView | OpenEditorsView | EmptyView; private lastFocusedView: ExplorerView | OpenEditorsView | EmptyView;
private focusListener: IDisposable; private focusListener: IDisposable;
...@@ -84,9 +86,13 @@ export class ExplorerViewlet extends Viewlet { ...@@ -84,9 +86,13 @@ export class ExplorerViewlet extends Viewlet {
public getActions(): IAction[] { public getActions(): IAction[] {
if (this.openEditorsVisible) { if (this.openEditorsVisible) {
return []; return [];
} else { }
if (this.explorerView) {
return this.explorerView.getActions(); return this.explorerView.getActions();
} }
return [];
} }
private onConfigurationUpdated(config: IFilesConfiguration): TPromise<void> { private onConfigurationUpdated(config: IFilesConfiguration): TPromise<void> {
...@@ -142,7 +148,7 @@ export class ExplorerViewlet extends Viewlet { ...@@ -142,7 +148,7 @@ export class ExplorerViewlet extends Viewlet {
} }
private addExplorerView(): void { private addExplorerView(): void {
let explorerView: ExplorerView | EmptyView; let explorerOrEmptyView: ExplorerView | EmptyView;
// With a Workspace // With a Workspace
if (this.contextService.getWorkspace()) { if (this.contextService.getWorkspace()) {
...@@ -179,20 +185,21 @@ export class ExplorerViewlet extends Viewlet { ...@@ -179,20 +185,21 @@ export class ExplorerViewlet extends Viewlet {
const explorerInstantiator = this.instantiationService.createChild(new ServiceCollection([IWorkbenchEditorService, delegatingEditorService])); const explorerInstantiator = this.instantiationService.createChild(new ServiceCollection([IWorkbenchEditorService, delegatingEditorService]));
const headerSize = this.openEditorsVisible ? undefined : 0; // If open editors are not visible set header size explicitly to 0, otherwise const it be computed by super class. const headerSize = this.openEditorsVisible ? undefined : 0; // If open editors are not visible set header size explicitly to 0, otherwise const it be computed by super class.
this.explorerView = explorerView = explorerInstantiator.createInstance(ExplorerView, this.viewletState, this.getActionRunner(), this.viewletSettings, headerSize); this.explorerView = explorerOrEmptyView = explorerInstantiator.createInstance(ExplorerView, this.viewletState, this.getActionRunner(), this.viewletSettings, headerSize);
} }
// No workspace // No workspace
else { else {
explorerView = this.instantiationService.createInstance(EmptyView); this.emptyView = explorerOrEmptyView = this.instantiationService.createInstance(EmptyView);
} }
if (this.openEditorsVisible) { if (this.openEditorsVisible) {
this.splitView.addView(explorerView); this.splitView.addView(explorerOrEmptyView);
} else { } else {
explorerView.render(this.viewletContainer.getHTMLElement(), Orientation.VERTICAL); explorerOrEmptyView.render(this.viewletContainer.getHTMLElement(), Orientation.VERTICAL);
} }
this.views.push(explorerView);
this.views.push(explorerOrEmptyView);
} }
public getExplorerView(): ExplorerView { public getExplorerView(): ExplorerView {
...@@ -214,12 +221,16 @@ export class ExplorerViewlet extends Viewlet { ...@@ -214,12 +221,16 @@ export class ExplorerViewlet extends Viewlet {
public focus(): void { public focus(): void {
super.focus(); super.focus();
const hasOpenedEditors = !!this.editorGroupService.getStacksModel().activeGroup;
if (this.lastFocusedView && this.lastFocusedView.isExpanded() && this.hasSelectionOrFocus(this.lastFocusedView)) { if (this.lastFocusedView && this.lastFocusedView.isExpanded() && this.hasSelectionOrFocus(this.lastFocusedView)) {
this.lastFocusedView.focusBody(); if (this.lastFocusedView !== this.openEditorsView || hasOpenedEditors) {
return; this.lastFocusedView.focusBody();
return;
}
} }
if (this.hasSelectionOrFocus(this.openEditorsView)) { if (this.hasSelectionOrFocus(this.openEditorsView) && hasOpenedEditors) {
return this.openEditorsView.focusBody(); return this.openEditorsView.focusBody();
} }
...@@ -227,14 +238,18 @@ export class ExplorerViewlet extends Viewlet { ...@@ -227,14 +238,18 @@ export class ExplorerViewlet extends Viewlet {
return this.explorerView.focusBody(); return this.explorerView.focusBody();
} }
if (this.openEditorsView && this.openEditorsView.isExpanded()) { if (this.openEditorsView && this.openEditorsView.isExpanded() && hasOpenedEditors) {
return this.openEditorsView.focusBody(); return this.openEditorsView.focusBody(); // we have entries in the opened editors view to focus on
} }
if (this.explorerView && this.explorerView.isExpanded()) { if (this.explorerView && this.explorerView.isExpanded()) {
return this.explorerView.focusBody(); return this.explorerView.focusBody();
} }
if (this.emptyView && this.emptyView.isExpanded()) {
return this.emptyView.focusBody();
}
return this.openEditorsView.focus(); return this.openEditorsView.focus();
} }
...@@ -262,6 +277,7 @@ export class ExplorerViewlet extends Viewlet { ...@@ -262,6 +277,7 @@ export class ExplorerViewlet extends Viewlet {
public layout(dimension: Dimension): void { public layout(dimension: Dimension): void {
this.dimension = dimension; this.dimension = dimension;
if (this.openEditorsVisible) { if (this.openEditorsVisible) {
this.splitView.layout(dimension.height); this.splitView.layout(dimension.height);
} else if (this.explorerView) { } else if (this.explorerView) {
...@@ -298,15 +314,22 @@ export class ExplorerViewlet extends Viewlet { ...@@ -298,15 +314,22 @@ export class ExplorerViewlet extends Viewlet {
this.splitView.dispose(); this.splitView.dispose();
this.splitView = null; this.splitView = null;
} }
if (this.explorerView) { if (this.explorerView) {
this.explorerView.dispose(); this.explorerView.dispose();
this.explorerView = null; this.explorerView = null;
} }
if (this.openEditorsView) { if (this.openEditorsView) {
this.openEditorsView.dispose(); this.openEditorsView.dispose();
this.openEditorsView = null; this.openEditorsView = null;
} }
if (this.emptyView) {
this.emptyView.dispose();
this.emptyView = null;
}
if (this.focusListener) { if (this.focusListener) {
this.focusListener.dispose(); this.focusListener.dispose();
this.focusListener = null; this.focusListener = null;
......
...@@ -18,6 +18,7 @@ import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/action ...@@ -18,6 +18,7 @@ import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/action
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
export class EmptyView extends CollapsibleView { export class EmptyView extends CollapsibleView {
private openFolderButton: Button;
constructor( @IInstantiationService private instantiationService: IInstantiationService) { constructor( @IInstantiationService private instantiationService: IInstantiationService) {
super({ super({
...@@ -39,9 +40,9 @@ export class EmptyView extends CollapsibleView { ...@@ -39,9 +40,9 @@ export class EmptyView extends CollapsibleView {
let section = $('div.section').appendTo(container); let section = $('div.section').appendTo(container);
let button = new Button(section); this.openFolderButton = new Button(section);
button.label = nls.localize('openFolder', "Open Folder"); this.openFolderButton.label = nls.localize('openFolder', "Open Folder");
button.addListener2('click', () => { this.openFolderButton.addListener2('click', () => {
this.runWorkbenchAction(env.isMacintosh ? 'workbench.action.files.openFileFolder' : 'workbench.action.files.openFolder'); this.runWorkbenchAction(env.isMacintosh ? 'workbench.action.files.openFileFolder' : 'workbench.action.files.openFolder');
}); });
} }
...@@ -68,7 +69,9 @@ export class EmptyView extends CollapsibleView { ...@@ -68,7 +69,9 @@ export class EmptyView extends CollapsibleView {
} }
public focusBody(): void { public focusBody(): void {
// Ignore if (this.openFolderButton) {
this.openFolderButton.getElement().focus();
}
} }
protected reveal(element: any, relativeTop?: number): TPromise<void> { protected reveal(element: any, relativeTop?: number): TPromise<void> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册