提交 036c2b0e 编写于 作者: B Benjamin Pasero

setInput: make options optional

上级 0763cc88
......@@ -67,7 +67,7 @@ export abstract class BaseEditor extends Panel implements IEditor {
* Sets the given input with the options to the part. An editor has to deal with the
* situation that the same input is being set with different options.
*/
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
public setInput(input: EditorInput, options?: EditorOptions): TPromise<void> {
this._input = input;
this._options = options;
......
......@@ -91,7 +91,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
$(this.rightScrollbar.getDomNode()).addClass('binarydiff-right');
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
public setInput(input: EditorInput, options?: EditorOptions): TPromise<void> {
const oldInput = this.getInput();
super.setInput(input, options);
......
......@@ -57,7 +57,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
parent.getHTMLElement().appendChild(this.scrollbar.getDomNode());
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
public setInput(input: EditorInput, options?: EditorOptions): TPromise<void> {
const oldInput = this.getInput();
super.setInput(input, options);
......
......@@ -47,7 +47,7 @@ export class SideBySideEditor extends BaseEditor {
this.createSash(parentElement);
}
public setInput(newInput: SideBySideEditorInput, options: EditorOptions): TPromise<void> {
public setInput(newInput: SideBySideEditorInput, options?: EditorOptions): TPromise<void> {
const oldInput = <SideBySideEditorInput>this.getInput();
return super.setInput(newInput, options)
.then(() => this.updateInput(oldInput, newInput, options));
......@@ -86,7 +86,7 @@ export class SideBySideEditor extends BaseEditor {
return null;
}
private updateInput(oldInput: SideBySideEditorInput, newInput: SideBySideEditorInput, options: EditorOptions): TPromise<void> {
private updateInput(oldInput: SideBySideEditorInput, newInput: SideBySideEditorInput, options?: EditorOptions): TPromise<void> {
if (!newInput.matches(oldInput)) {
if (oldInput) {
this.disposeEditors();
......@@ -94,19 +94,19 @@ export class SideBySideEditor extends BaseEditor {
this.createEditorContainers();
return this.setNewInput(newInput, options);
} else {
this.detailsEditor.setInput(newInput.details, new EditorOptions());
this.detailsEditor.setInput(newInput.details);
this.masterEditor.setInput(newInput.master, options);
}
}
private setNewInput(newInput: SideBySideEditorInput, options: EditorOptions): TPromise<void> {
private setNewInput(newInput: SideBySideEditorInput, options?: EditorOptions): TPromise<void> {
return TPromise.join([
this._createEditor(<EditorInput>newInput.details, this.detailsEditorContainer, new EditorOptions()), //TODO@ben why do you have to provide options
this._createEditor(<EditorInput>newInput.details, this.detailsEditorContainer),
this._createEditor(<EditorInput>newInput.master, this.masterEditorContainer, options)
]).then(result => this.onEditorsCreated(result[0], result[1]));
}
private _createEditor(editorInput: EditorInput, container: HTMLElement, options: EditorOptions): TPromise<BaseEditor> {
private _createEditor(editorInput: EditorInput, container: HTMLElement, options?: EditorOptions): TPromise<BaseEditor> {
const descriptor = Registry.as<IEditorRegistry>(EditorExtensions.Editors).getEditor(editorInput);
if (!descriptor) {
return TPromise.wrapError(new Error(strings.format('Can not find a registered editor for the input {0}', editorInput)));
......
......@@ -68,7 +68,7 @@ export class StringEditor extends BaseTextEditor {
return nls.localize('textEditor', "Text Editor");
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
public setInput(input: EditorInput, options?: EditorOptions): TPromise<void> {
const oldInput = this.getInput();
super.setInput(input, options);
......
......@@ -117,7 +117,7 @@ export class TextDiffEditor extends BaseTextEditor {
return diffEditorInstantiator.createInstance(DiffEditorWidget, parent.getHTMLElement(), this.getCodeEditorOptions());
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
public setInput(input: EditorInput, options?: EditorOptions): TPromise<void> {
const oldInput = this.getInput();
super.setInput(input, options);
......
......@@ -142,7 +142,7 @@ export abstract class BaseTextEditor extends BaseEditor {
return this.instantiationService.createInstance(CodeEditor, parent.getHTMLElement(), this.getCodeEditorOptions());
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
public setInput(input: EditorInput, options?: EditorOptions): TPromise<void> {
return super.setInput(input, options).then(() => {
this.editorControl.updateOptions(this.getCodeEditorOptions()); // support input specific editor options
});
......
......@@ -29,7 +29,7 @@ export class DebugErrorEditor extends BaseEditor {
this.container.style.height = `${dimension.height}px`;
}
public setInput(input: DebugErrorEditorInput, options: EditorOptions): TPromise<void> {
public setInput(input: DebugErrorEditorInput, options?: EditorOptions): TPromise<void> {
this.container.textContent = input.value;
return super.setInput(input, options);
}
......
......@@ -83,7 +83,7 @@ export class TextFileEditor extends BaseTextEditor {
return <FileEditorInput>super.getInput();
}
public setInput(input: FileEditorInput, options: EditorOptions): TPromise<void> {
public setInput(input: FileEditorInput, options?: EditorOptions): TPromise<void> {
const oldInput = this.getInput();
super.setInput(input, options);
......
......@@ -138,7 +138,7 @@ export class HtmlPreviewPart extends BaseEditor {
this.webview.focus();
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
public setInput(input: EditorInput, options?: EditorOptions): TPromise<void> {
if (this.input === input && this._hasValidModel()) {
return TPromise.as(undefined);
......
......@@ -98,7 +98,7 @@ export class OutputPanel extends StringEditor {
return options;
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
public setInput(input: EditorInput, options?: EditorOptions): TPromise<void> {
return super.setInput(input, options).then(() => this.revealLastLine());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册