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

Edits made within the peek view do not create an open editor. (fixes #7621)

上级 57c833a8
......@@ -162,6 +162,12 @@ export interface IEditorOptionsBag {
* The index in the document stack where to insert the editor into when opening.
*/
index?: number;
/**
* An active editor that is opened will show its contents directly. Set to true to open an editor
* in the background.
*/
inactive?: boolean;
}
export interface ITextEditorOptions extends IEditorOptionsBag {
......
......@@ -235,7 +235,13 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// stacks model gets updated if any of the UI updating fails with an error.
const group = this.ensureGroup(position, !options || !options.preserveFocus);
const pinned = !this.previewEditors || (options && (options.pinned || typeof options.index === 'number')) || input.isDirty();
group.openEditor(input, { active: true, pinned, index: options && options.index });
const active = (group.count === 0) || !options || !options.inactive;
group.openEditor(input, { active, pinned, index: options && options.index });
// Return early if the editor is to be open inactive and there are other editors in this group to show
if (!active) {
return TPromise.as<BaseEditor>(null);
}
// Progress Monitor & Ref Counting
this.editorOpenToken[position]++;
......
......@@ -336,13 +336,15 @@ export class EditorOptions implements IEditorOptions {
preserveFocus?: boolean;
forceOpen?: boolean;
pinned?: boolean,
index?: number
index?: number,
inactive?: boolean
}): EditorOptions {
let options = new EditorOptions();
options.preserveFocus = settings.preserveFocus;
options.forceOpen = settings.forceOpen;
options.pinned = settings.pinned;
options.index = settings.index;
options.inactive = settings.inactive;
return options;
}
......@@ -380,6 +382,12 @@ export class EditorOptions implements IEditorOptions {
* The index in the document stack where to insert the editor into when opening.
*/
public index: number;
/**
* An active editor that is opened will show its contents directly. Set to true to open an editor
* in the background.
*/
public inactive: boolean;
}
/**
......@@ -395,7 +403,7 @@ export class TextEditorOptions extends EditorOptions {
public static from(input: IResourceInput): TextEditorOptions {
let options: TextEditorOptions = null;
if (input && input.options) {
if (input.options.selection || input.options.forceOpen || input.options.preserveFocus || input.options.pinned || typeof input.options.index === 'number') {
if (input.options.selection || input.options.forceOpen || input.options.preserveFocus || input.options.pinned || input.options.inactive || typeof input.options.index === 'number') {
options = new TextEditorOptions();
}
......@@ -416,6 +424,10 @@ export class TextEditorOptions extends EditorOptions {
options.pinned = true;
}
if (input.options.inactive) {
options.inactive = true;
}
if (typeof input.options.index === 'number') {
options.index = input.options.index;
}
......
......@@ -85,6 +85,11 @@ export class FileTracker implements IWorkbenchContribution {
if (this.textFileService.getAutoSaveMode() !== AutoSaveMode.AFTER_SHORT_DELAY) {
this.updateActivityBadge(); // no indication needed when auto save is enabled for short delay
}
// If a file becomes dirty but is not opened, we open it in the background
if (!this.stacks.isOpen(e.resource)) {
this.editorService.openEditor({ resource: e.resource, options: { inactive: true } }).done(null, errors.onUnexpectedError);
}
}
private onTextFileSaveError(e: TextFileChangeEvent): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册