提交 37a5a81b 编写于 作者: B Benjamin Pasero

very first stacks model integration to editor open

上级 03c39a24
......@@ -38,7 +38,7 @@ import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollect
import {IMessageService, IMessageWithAction, Severity} from 'vs/platform/message/common/message';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IProgressService} from 'vs/platform/progress/common/progress';
import {EditorStacksModel} from 'vs/workbench/common/editor/editorStacksModel';
import {EditorStacksModel, EditorGroup} from 'vs/workbench/common/editor/editorStacksModel';
const EDITOR_STATE_STORAGE_KEY = 'editorpart.editorState';
......@@ -417,11 +417,19 @@ export class EditorPart extends Part implements IEditorPart {
return editor;
}
const preserveFocus = options && options.preserveFocus;
const pinned = options && options.pinned;
const index = options && options.index;
// Focus (unless prevented)
if (!options || !options.preserveFocus) {
if (!preserveFocus) {
editor.focus();
}
// Update stacks
const group = this.ensureGroup(position, !preserveFocus);
group.openEditor(input, { active: true, pinned, index });
// Progress Done
this.sideBySideControl.updateProgress(position, ProgressState.DONE);
......@@ -1022,4 +1030,17 @@ export class EditorPart extends Part implements IEditorPart {
array[to] = array[from];
array[from] = empty;
}
private ensureGroup(position: Position, activate = true): EditorGroup {
let group = this.stacksModel.groups[position];
if (!group) {
group = this.stacksModel.openGroup(position === Position.LEFT ? nls.localize('leftGroup', "Left") : position === Position.CENTER ? nls.localize('centerGroup', "Center") : nls.localize('rightGroup', "Right"), activate);
}
if (activate) {
this.stacksModel.setActive(group);
}
return group;
}
}
\ No newline at end of file
......@@ -696,6 +696,10 @@ export class EditorStacksModel implements IEditorStacksModel {
}
public setActive(group: EditorGroup): void {
if (this.active === group) {
return;
}
this.active = group;
this._onGroupActivated.fire(this.active);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册