Merge from vscode 91e99652cd5fcfc072387c64e151b435e39e8dcf (#6962)

This commit is contained in:
Anthony Dresser
2019-08-26 15:58:42 -07:00
committed by GitHub
parent edf470c8fa
commit 507bae90b7
103 changed files with 1743 additions and 1543 deletions

View File

@@ -9,7 +9,7 @@ import { isUndefinedOrNull } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
import { IEditor as ICodeEditor, IEditorViewState, ScrollType, IDiffEditor } from 'vs/editor/common/editorCommon';
import { IEditorModel, IEditorOptions, ITextEditorOptions, IBaseResourceInput, IResourceInput } from 'vs/platform/editor/common/editor';
import { IEditorModel, IEditorOptions, ITextEditorOptions, IBaseResourceInput, IResourceInput, EditorActivation } from 'vs/platform/editor/common/editor';
import { IInstantiationService, IConstructorSignature0, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { Registry } from 'vs/platform/registry/common/platform';
@@ -718,25 +718,28 @@ export class EditorOptions implements IEditorOptions {
*/
static create(settings: IEditorOptions): EditorOptions {
const options = new EditorOptions();
options.preserveFocus = settings.preserveFocus;
options.forceReload = settings.forceReload;
options.revealIfVisible = settings.revealIfVisible;
options.revealIfOpened = settings.revealIfOpened;
options.pinned = settings.pinned;
options.index = settings.index;
options.inactive = settings.inactive;
options.ignoreError = settings.ignoreError;
options.overwrite(settings);
return options;
}
/**
* Tells the editor to not receive keyboard focus when the editor is being opened. By default,
* the editor will receive keyboard focus on open.
* Tells the editor to not receive keyboard focus when the editor is being opened.
*
* Will also not activate the group the editor opens in unless the group is already
* the active one. This behaviour can be overridden via the `activation` option.
*/
preserveFocus: boolean | undefined;
/**
* This option is only relevant if an editor is opened into a group that is not active
* already and allows to control if the inactive group should become active or not.
*
* By default, the editor group will become active unless `preserveFocus` or `inactive`
* is specified.
*/
activation: EditorActivation | undefined;
/**
* Tells the editor to reload the editor input in the editor even if it is identical to the one
* already showing. By default, the editor will not reload the input if it is identical to the
@@ -767,7 +770,10 @@ export class EditorOptions implements IEditorOptions {
/**
* An active editor that is opened will show its contents directly. Set to true to open an editor
* in the background.
* in the background without loading its contents.
*
* Will also not activate the group the editor opens in unless the group is already
* the active one. This behaviour can be overridden via the `activation` option.
*/
inactive: boolean | undefined;
@@ -776,6 +782,49 @@ export class EditorOptions implements IEditorOptions {
* message as needed. By default, an error will be presented as notification if opening was not possible.
*/
ignoreError: boolean | undefined;
/**
* Overwrites option values from the provided bag.
*/
overwrite(options: IEditorOptions): EditorOptions {
if (typeof options.forceReload === 'boolean') {
this.forceReload = options.forceReload;
}
if (typeof options.revealIfVisible === 'boolean') {
this.revealIfVisible = options.revealIfVisible;
}
if (typeof options.revealIfOpened === 'boolean') {
this.revealIfOpened = options.revealIfOpened;
}
if (typeof options.preserveFocus === 'boolean') {
this.preserveFocus = options.preserveFocus;
}
if (typeof options.activation === 'number') {
this.activation = options.activation;
}
if (typeof options.pinned === 'boolean') {
this.pinned = options.pinned;
}
if (typeof options.inactive === 'boolean') {
this.inactive = options.inactive;
}
if (typeof options.ignoreError === 'boolean') {
this.ignoreError = options.ignoreError;
}
if (typeof options.index === 'number') {
this.index = options.index;
}
return this;
}
}
/**
@@ -803,53 +852,31 @@ export class TextEditorOptions extends EditorOptions {
*/
static create(options: ITextEditorOptions = Object.create(null)): TextEditorOptions {
const textEditorOptions = new TextEditorOptions();
textEditorOptions.overwrite(options);
return textEditorOptions;
}
/**
* Overwrites option values from the provided bag.
*/
overwrite(options: ITextEditorOptions): TextEditorOptions {
super.overwrite(options);
if (options.selection) {
const selection = options.selection;
textEditorOptions.selection(selection.startLineNumber, selection.startColumn, selection.endLineNumber, selection.endColumn);
this.selection(selection.startLineNumber, selection.startColumn, selection.endLineNumber, selection.endColumn);
}
if (options.viewState) {
textEditorOptions.editorViewState = options.viewState as IEditorViewState;
this.editorViewState = options.viewState as IEditorViewState;
}
if (options.forceReload) {
textEditorOptions.forceReload = true;
if (typeof options.revealInCenterIfOutsideViewport === 'boolean') {
this.revealInCenterIfOutsideViewport = options.revealInCenterIfOutsideViewport;
}
if (options.revealIfVisible) {
textEditorOptions.revealIfVisible = true;
}
if (options.revealIfOpened) {
textEditorOptions.revealIfOpened = true;
}
if (options.preserveFocus) {
textEditorOptions.preserveFocus = true;
}
if (options.revealInCenterIfOutsideViewport) {
textEditorOptions.revealInCenterIfOutsideViewport = true;
}
if (options.pinned) {
textEditorOptions.pinned = true;
}
if (options.inactive) {
textEditorOptions.inactive = true;
}
if (options.ignoreError) {
textEditorOptions.ignoreError = true;
}
if (typeof options.index === 'number') {
textEditorOptions.index = options.index;
}
return textEditorOptions;
return this;
}
/**