提交 bcaae69c 编写于 作者: B Benjamin Pasero

Revert "Provide an option to stop scrolling revealing active file in explorer (fixes #3062)"

This reverts commit 9a15f9e3.
上级 f71fec3d
......@@ -272,6 +272,7 @@ export class CollapseAction extends Action {
export interface IViewletView {
create(): TPromise<void>;
refresh(focus: boolean, reveal: boolean, instantProgress?: boolean): TPromise<void>;
setVisible(visible: boolean): TPromise<void>;
getActions(): IAction[];
getSecondaryActions(): IAction[];
......@@ -349,10 +350,14 @@ export class AdaptiveCollapsibleViewletView extends FixedCollapsibleView impleme
return this.tree;
}
public refresh(focus: boolean, reveal: boolean, instantProgress?: boolean): TPromise<void> {
return TPromise.as(null);
}
public setVisible(visible: boolean): TPromise<void> {
this.isVisible = visible;
updateTreeVisibility(this.tree, visible && this.state === CollapsibleState.EXPANDED);
updateTreeVisibility(this.tree, this.state === CollapsibleState.EXPANDED);
return TPromise.as(null);
}
......@@ -472,10 +477,14 @@ export class CollapsibleViewletView extends CollapsibleView implements IViewletV
return this.tree;
}
public refresh(focus: boolean, reveal: boolean, instantProgress?: boolean): TPromise<void> {
return TPromise.as(null);
}
public setVisible(visible: boolean): TPromise<void> {
this.isVisible = visible;
updateTreeVisibility(this.tree, visible && this.state === CollapsibleState.EXPANDED);
updateTreeVisibility(this.tree, this.state === CollapsibleState.EXPANDED);
return TPromise.as(null);
}
......@@ -563,7 +572,7 @@ function focus(tree: ITree): void {
// Make sure the current selected element is revealed
let selection = tree.getSelection();
if (selection.length > 0) {
reveal(tree, selection[0], 0.5).done(null, errors.onUnexpectedError);
reveal(tree, selection[0], 0.5);
}
// Pass Focus to Viewer
......
......@@ -96,6 +96,16 @@ export class ExplorerViewlet extends Viewlet {
this.views.push(explorerView);
}
/**
* Refresh the contents of the explorer to get up to date data from the disk about the file structure.
*
* @param focus if set to true, the explorer viewer will receive keyboard focus
* @param reveal if set to true, the current active input will be revealed in the explorer
*/
public refresh(focus: boolean, reveal: boolean, instantProgress?: boolean): TPromise<void> {
return TPromise.join(this.views.map((view) => view.refresh(focus, reveal, instantProgress))).then(() => void 0);
}
public getExplorerView(): ExplorerView {
return this.explorerView;
}
......
......@@ -1391,9 +1391,9 @@ export class RefreshViewExplorerAction extends Action {
return TPromise.as(null); // Global action disabled if user is in edit mode from another action
}
explorerView.getViewer().DOMFocus();
explorerView.focusBody();
return explorerView.refresh();
return explorerView.refresh(true, true, true);
});
}
}
......
......@@ -251,11 +251,6 @@ configurationRegistry.registerConfiguration({
'type': 'boolean',
'description': nls.localize('dynamicHeight', "Controls if the height of the working files section should adapt dynamically to the number of elements or not."),
'default': true
},
'explorer.autoReveal': {
'type': 'boolean',
'description': nls.localize('autoReveal', "Controls if the explorer should automatically reveal files when opening them."),
'default': true
}
}
});
......
......@@ -60,6 +60,10 @@ export class EmptyView extends CollapsibleView {
return TPromise.as(null);
}
public refresh(focus: boolean, reveal: boolean, instantProgress?: boolean): TPromise<void> {
return TPromise.as(null);
}
public setVisible(visible: boolean): TPromise<void> {
return TPromise.as(null);
}
......
......@@ -58,8 +58,6 @@ export class ExplorerView extends CollapsibleViewletView {
private shouldRefresh: boolean;
private autoReveal: boolean;
private settings: any;
constructor(
......@@ -85,7 +83,6 @@ export class ExplorerView extends CollapsibleViewletView {
this.settings = settings;
this.viewletState = viewletState;
this.actionRunner = actionRunner;
this.autoReveal = true;
this.explorerRefreshDelayer = new ThrottledDelayer<void>(ExplorerView.EXPLORER_FILE_CHANGES_REFRESH_DELAY);
this.explorerImportDelayer = new ThrottledDelayer<void>(ExplorerView.EXPLORER_IMPORT_REFRESH_DELAY);
......@@ -138,7 +135,7 @@ export class ExplorerView extends CollapsibleViewletView {
this.onConfigurationUpdated(configuration);
// Load and Fill Viewer
return this.doRefresh().then(() => {
return this.refresh(false, false).then(() => {
// When the explorer viewer is loaded, listen to changes to the editor input
this.toDispose.push(this.eventService.addListener2(WorkbenchEventType.EDITOR_INPUT_CHANGING, (e: EditorEvent) => this.onEditorInputChanging(e)));
......@@ -183,7 +180,6 @@ export class ExplorerView extends CollapsibleViewletView {
}
private onConfigurationUpdated(configuration: IFilesConfiguration, refresh?: boolean): void {
this.autoReveal = configuration && configuration.explorer && configuration.explorer.autoReveal;
// Push down config updates to components of viewer
let needsRefresh = false;
......@@ -193,24 +189,12 @@ export class ExplorerView extends CollapsibleViewletView {
// Refresh viewer as needed
if (refresh && needsRefresh) {
this.doRefresh().done(null, errors.onUnexpectedError);
this.refresh(false, false).done(null, errors.onUnexpectedError);
}
}
public focusBody(): void {
// Make sure the current selected element is revealed
if (this.explorerViewer) {
if (this.autoReveal) {
let selection = this.explorerViewer.getSelection();
if (selection.length > 0) {
this.reveal(selection[0], 0.5).done(null, errors.onUnexpectedError);
}
}
// Pass Focus to Viewer
this.explorerViewer.DOMFocus();
}
super.focusBody();
// Open the focused element in the editor if there is currently no file opened
let input = this.editorService.getActiveEditorInput();
......@@ -228,7 +212,7 @@ export class ExplorerView extends CollapsibleViewletView {
// If a refresh was requested and we are now visible, run it
let refreshPromise = TPromise.as(null);
if (this.shouldRefresh) {
refreshPromise = this.doRefresh();
refreshPromise = this.refresh(false, false);
this.shouldRefresh = false; // Reset flag
}
......@@ -236,7 +220,7 @@ export class ExplorerView extends CollapsibleViewletView {
let activeResource = this.getActiveEditorInputResource();
if (activeResource) {
return refreshPromise.then(() => {
return this.select(activeResource, this.autoReveal);
return this.select(activeResource);
});
}
......@@ -597,7 +581,7 @@ export class ExplorerView extends CollapsibleViewletView {
if (this.isVisible) {
this.explorerRefreshDelayer.trigger(() => {
if (!this.explorerViewer.getHighlight()) {
return this.doRefresh();
return this.refresh(false, false);
}
return TPromise.as(null);
......@@ -609,12 +593,11 @@ export class ExplorerView extends CollapsibleViewletView {
/**
* Refresh the contents of the explorer to get up to date data from the disk about the file structure.
*
* @param focus if set to true, the explorer viewer will receive keyboard focus
* @param reveal if set to true, the current active input will be revealed in the explorer
*/
public refresh(): TPromise<void> {
return this.doRefresh(this.autoReveal);
}
private doRefresh(reveal?: boolean): TPromise<void> {
public refresh(focus: boolean, reveal: boolean, instantProgress?: boolean): TPromise<void> {
let root = this.getInput();
let targetsToResolve: URI[] = [];
let targetsToExpand: URI[] = [];
......@@ -690,11 +673,17 @@ export class ExplorerView extends CollapsibleViewletView {
revealPromise = TPromise.as(null);
}
return revealPromise;
return revealPromise.then(() => {
// Focus if set
if (focus) {
this.explorerViewer.DOMFocus();
}
});
});
}, (e: any) => TPromise.wrapError(e));
this.progressService.showWhile(promise, this.partService.isCreated() ? 800 : 3200 /* less ugly initial startup */);
this.progressService.showWhile(promise, instantProgress ? 0 : this.partService.isCreated() ? 800 : 3200 /* less ugly initial startup */);
return promise;
}
......@@ -730,7 +719,7 @@ export class ExplorerView extends CollapsibleViewletView {
* Selects and reveal the file element provided by the given resource if its found in the explorer. Will try to
* resolve the path from the disk in case the explorer is not yet expanded to the file yet.
*/
public select(resource: URI, reveal: boolean = this.autoReveal): TPromise<void> {
public select(resource: URI, reveal: boolean = true): TPromise<void> {
// Require valid path
if (!resource || resource.toString() === this.workspace.resource.toString()) {
......@@ -753,7 +742,7 @@ export class ExplorerView extends CollapsibleViewletView {
let fileStat = root.find(resource);
if (fileStat) {
return this.doSelect(fileStat, reveal);
return this.doRevealAndSelect(fileStat);
}
// Stat needs to be resolved first and then revealed
......@@ -768,12 +757,12 @@ export class ExplorerView extends CollapsibleViewletView {
// Select and Reveal
return this.explorerViewer.refresh(root).then(() => {
return this.doSelect(root.find(resource), reveal);
return this.doRevealAndSelect(root.find(resource));
});
}, (e: any) => this.messageService.show(Severity.Error, e));
}
private doSelect(fileStat: FileStat, reveal: boolean): TPromise<void> {
private doRevealAndSelect(fileStat: FileStat): TPromise<void> {
if (!fileStat) {
return TPromise.as(null);
}
......@@ -787,15 +776,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
}
// Reveal depending on flag
let revealPromise: TPromise<void>;
if (reveal) {
revealPromise = this.reveal(fileStat, 0.5);
} else {
revealPromise = TPromise.as(null);
}
return revealPromise.then(() => {
return this.reveal(fileStat, 0.5).then(() => {
if (!fileStat.isDirectory) {
this.explorerViewer.setSelection([fileStat]); // Since folders can not be opened, only select files
}
......
......@@ -67,7 +67,6 @@ export interface IFilesConfiguration extends IFilesConfiguration {
maxVisible: number;
dynamicHeight: boolean;
};
autoReveal: boolean;
};
editor: IEditorOptions;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册