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

adopt revealIfOpened in some places

上级 2ecaa685
......@@ -380,7 +380,7 @@ export class ReplExpressionsRenderer implements tree.IRenderer {
event.preventDefault();
this.editorService.openEditor({
resource: resource,
resource,
options: {
selection: {
startLineNumber: line,
......
......@@ -23,7 +23,6 @@ import {FileEditorInput} from 'vs/workbench/parts/files/common/editors/fileEdito
import {FileDragAndDrop, FileFilter, FileSorter, FileController, FileRenderer, FileDataSource, FileViewletState, FileAccessibilityProvider} from 'vs/workbench/parts/files/browser/views/explorerViewer';
import lifecycle = require('vs/base/common/lifecycle');
import {UntitledEditorInput} from 'vs/workbench/common/editor/untitledEditorInput';
import {IEditor} from 'vs/platform/editor/common/editor';
import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService';
import * as DOM from 'vs/base/browser/dom';
import {CollapseAction, CollapsibleViewletView} from 'vs/workbench/browser/viewlet';
......@@ -267,7 +266,7 @@ export class ExplorerView extends CollapsibleViewletView {
if (lastActiveFileResource && root && root.find(lastActiveFileResource)) {
let editorInput = this.instantiationService.createInstance(FileEditorInput, lastActiveFileResource, void 0, void 0);
this.activateOrOpenEditor(editorInput).done(null, errors.onUnexpectedError);
this.editorService.openEditor(editorInput, { revealIfOpened: true }).done(null, errors.onUnexpectedError);
return refreshPromise;
}
......@@ -280,36 +279,15 @@ export class ExplorerView extends CollapsibleViewletView {
});
}
private openFocusedElement(keepFocus?: boolean): void {
private openFocusedElement(preserveFocus?: boolean): void {
let stat: FileStat = this.explorerViewer.getFocus();
if (stat && !stat.isDirectory) {
let editorInput = this.instantiationService.createInstance(FileEditorInput, stat.resource, stat.mime, void 0);
this.activateOrOpenEditor(editorInput, keepFocus).done(null, errors.onUnexpectedError);
this.editorService.openEditor(editorInput, { preserveFocus, revealIfOpened: true }).done(null, errors.onUnexpectedError);
}
}
private activateOrOpenEditor(input: FileEditorInput, keepFocus?: boolean): TPromise<IEditor> {
// First try to find if input already visible
let editors = this.editorService.getVisibleEditors();
if (editors) {
for (let i = 0; i < editors.length; i++) {
let editor = editors[i];
if (input.matches(editor.input)) {
if (!keepFocus) {
this.editorGroupService.focusGroup(editor.position);
}
return TPromise.as(editor);
}
}
}
// Otherwise open in active slot
return this.editorService.openEditor(input, keepFocus ? { preserveFocus: true } : void 0);
}
private getActiveEditorInputResource(): URI {
// Try with Editor Input
......@@ -343,9 +321,9 @@ export class ExplorerView extends CollapsibleViewletView {
dnd: dnd,
accessibilityProvider: accessibility
}, {
autoExpandSingleChildren: true,
ariaLabel: nls.localize('treeAriaLabel', "Files Explorer")
});
autoExpandSingleChildren: true,
ariaLabel: nls.localize('treeAriaLabel', "Files Explorer")
});
this.toDispose.push(lifecycle.toDisposable(() => renderer.dispose()));
......
......@@ -59,8 +59,8 @@ export class Controller extends treedefaults.DefaultController {
endLineNumber: marker.endLineNumber,
endColumn: marker.endColumn
},
preserveFocus: preserveFocus,
pinned: pinned
preserveFocus,
pinned
},
}, sideByside).done(null, errors.onUnexpectedError);
return true;
......
......@@ -911,9 +911,9 @@ export class SearchViewlet extends Viewlet {
return this.editorService.openEditor({
resource: resource,
options: {
preserveFocus: preserveFocus,
pinned: pinned,
selection: selection
preserveFocus,
pinned,
selection
}
}, sideBySide);
}
......
......@@ -15,7 +15,7 @@ import {BaseTextEditor} from 'vs/workbench/browser/parts/editor/textEditor';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {IHistoryService} from 'vs/workbench/services/history/common/history';
import {Selection} from 'vs/editor/common/core/selection';
import {Position, IEditorInput, ITextEditorOptions} from 'vs/platform/editor/common/editor';
import {IEditorInput, ITextEditorOptions} from 'vs/platform/editor/common/editor';
import {IEventService} from 'vs/platform/event/common/event';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
......@@ -311,8 +311,15 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
private navigate(): void {
let state = this.stack[this.index];
let options = state.options;
if (options) {
options.revealIfOpened = true;
} else {
options = { revealIfOpened: true };
}
this.blockStackChanges = true;
this.editorService.openEditor(state.input, state.options, this.findVisibleEditorPosition(state.input)).done(() => {
this.editorService.openEditor(state.input, options).done(() => {
this.blockStackChanges = false;
}, (error) => {
this.blockStackChanges = false;
......@@ -320,23 +327,6 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
});
}
private findVisibleEditorPosition(input: IEditorInput): Position {
let activeEditor = this.editorService.getActiveEditor();
if (activeEditor && input.matches(activeEditor.input)) {
return activeEditor.position;
}
let editors = this.editorService.getVisibleEditors();
for (let i = 0; i < editors.length; i++) {
let editor = editors[i];
if (editor !== activeEditor && input.matches(editor.input)) {
return editor.position;
}
}
return null;
}
protected handleEditorSelectionChangeEvent(editor?: IBaseEditor): void {
this.handleEditorEventInStack(editor, true);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册