提交 7e1a7742 编写于 作者: B Benjamin Pasero

let => const

上级 60211895
...@@ -86,7 +86,7 @@ export abstract class BaseEditor extends Panel implements IEditor { ...@@ -86,7 +86,7 @@ export abstract class BaseEditor extends Panel implements IEditor {
public create(parent: Builder): void; // create is sync for editors public create(parent: Builder): void; // create is sync for editors
public create(parent: Builder): TPromise<void>; public create(parent: Builder): TPromise<void>;
public create(parent: Builder): TPromise<void> { public create(parent: Builder): TPromise<void> {
let res = super.create(parent); const res = super.create(parent);
// Create Editor // Create Editor
this.createEditor(parent); this.createEditor(parent);
...@@ -105,7 +105,7 @@ export abstract class BaseEditor extends Panel implements IEditor { ...@@ -105,7 +105,7 @@ export abstract class BaseEditor extends Panel implements IEditor {
public setVisible(visible: boolean, position?: Position): void; // setVisible is sync for editors public setVisible(visible: boolean, position?: Position): void; // setVisible is sync for editors
public setVisible(visible: boolean, position?: Position): TPromise<void>; public setVisible(visible: boolean, position?: Position): TPromise<void>;
public setVisible(visible: boolean, position: Position = null): TPromise<void> { public setVisible(visible: boolean, position: Position = null): TPromise<void> {
let promise = super.setVisible(visible); const promise = super.setVisible(visible);
// Propagate to Editor // Propagate to Editor
this.setEditorVisible(visible, position); this.setEditorVisible(visible, position);
...@@ -185,7 +185,7 @@ class EditorRegistry implements IEditorRegistry { ...@@ -185,7 +185,7 @@ class EditorRegistry implements IEditorRegistry {
this.instantiationService = service; this.instantiationService = service;
for (let key in this.editorInputFactoryConstructors) { for (let key in this.editorInputFactoryConstructors) {
let element = this.editorInputFactoryConstructors[key]; const element = this.editorInputFactoryConstructors[key];
this.createEditorInputFactory(key, element); this.createEditorInputFactory(key, element);
} }
...@@ -193,7 +193,7 @@ class EditorRegistry implements IEditorRegistry { ...@@ -193,7 +193,7 @@ class EditorRegistry implements IEditorRegistry {
} }
private createEditorInputFactory(editorInputId: string, ctor: IConstructorSignature0<IEditorInputFactory>): void { private createEditorInputFactory(editorInputId: string, ctor: IConstructorSignature0<IEditorInputFactory>): void {
let instance = this.instantiationService.createInstance(ctor); const instance = this.instantiationService.createInstance(ctor);
this.editorInputFactoryInstances[editorInputId] = instance; this.editorInputFactoryInstances[editorInputId] = instance;
} }
...@@ -215,14 +215,14 @@ class EditorRegistry implements IEditorRegistry { ...@@ -215,14 +215,14 @@ class EditorRegistry implements IEditorRegistry {
} }
public getEditor(input: EditorInput): EditorDescriptor { public getEditor(input: EditorInput): EditorDescriptor {
let findEditorDescriptors = (input: EditorInput, byInstanceOf?: boolean): EditorDescriptor[]=> { const findEditorDescriptors = (input: EditorInput, byInstanceOf?: boolean): EditorDescriptor[]=> {
let matchingDescriptors: EditorDescriptor[] = []; const matchingDescriptors: EditorDescriptor[] = [];
for (let i = 0; i < this.editors.length; i++) { for (let i = 0; i < this.editors.length; i++) {
let editor = this.editors[i]; const editor = this.editors[i];
let inputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY]; const inputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY];
for (let j = 0; j < inputDescriptors.length; j++) { for (let j = 0; j < inputDescriptors.length; j++) {
let inputClass = inputDescriptors[j].ctor; const inputClass = inputDescriptors[j].ctor;
// Direct check on constructor type (ignores prototype chain) // Direct check on constructor type (ignores prototype chain)
if (!byInstanceOf && (<any>input).constructor === inputClass) { if (!byInstanceOf && (<any>input).constructor === inputClass) {
...@@ -250,11 +250,11 @@ class EditorRegistry implements IEditorRegistry { ...@@ -250,11 +250,11 @@ class EditorRegistry implements IEditorRegistry {
return matchingDescriptors; return matchingDescriptors;
}; };
let descriptors = findEditorDescriptors(input); const descriptors = findEditorDescriptors(input);
if (descriptors && descriptors.length > 0) { if (descriptors && descriptors.length > 0) {
// Ask the input for its preferred Editor // Ask the input for its preferred Editor
let preferredEditorId = input.getPreferredEditorId(descriptors.map(d => d.getId())); const preferredEditorId = input.getPreferredEditorId(descriptors.map(d => d.getId()));
if (preferredEditorId) { if (preferredEditorId) {
return this.getEditorById(preferredEditorId); return this.getEditorById(preferredEditorId);
} }
...@@ -268,7 +268,7 @@ class EditorRegistry implements IEditorRegistry { ...@@ -268,7 +268,7 @@ class EditorRegistry implements IEditorRegistry {
public getEditorById(editorId: string): EditorDescriptor { public getEditorById(editorId: string): EditorDescriptor {
for (let i = 0; i < this.editors.length; i++) { for (let i = 0; i < this.editors.length; i++) {
let editor = this.editors[i]; const editor = this.editors[i];
if (editor.getId() === editorId) { if (editor.getId() === editorId) {
return editor; return editor;
} }
...@@ -286,10 +286,10 @@ class EditorRegistry implements IEditorRegistry { ...@@ -286,10 +286,10 @@ class EditorRegistry implements IEditorRegistry {
} }
public getEditorInputs(): any[] { public getEditorInputs(): any[] {
let inputClasses: any[] = []; const inputClasses: any[] = [];
for (let i = 0; i < this.editors.length; i++) { for (let i = 0; i < this.editors.length; i++) {
let editor = this.editors[i]; const editor = this.editors[i];
let editorInputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY]; const editorInputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY];
inputClasses.push(...editorInputDescriptors.map(descriptor=> descriptor.ctor)); inputClasses.push(...editorInputDescriptors.map(descriptor=> descriptor.ctor));
} }
...@@ -346,7 +346,7 @@ export class EditorInputActionContributor extends ActionBarContributor { ...@@ -346,7 +346,7 @@ export class EditorInputActionContributor extends ActionBarContributor {
} }
private createPositionArray(): any[] { private createPositionArray(): any[] {
let array: any[] = []; const array: any[] = [];
for (let i = 0; i < POSITIONS.length; i++) { for (let i = 0; i < POSITIONS.length; i++) {
array[i] = {}; array[i] = {};
...@@ -371,7 +371,7 @@ export class EditorInputActionContributor extends ActionBarContributor { ...@@ -371,7 +371,7 @@ export class EditorInputActionContributor extends ActionBarContributor {
private doClearInputsFromCache(cache: { [id: string]: IEditorInputAction[] }): void { private doClearInputsFromCache(cache: { [id: string]: IEditorInputAction[] }): void {
for (let key in cache) { for (let key in cache) {
if (cache.hasOwnProperty(key)) { if (cache.hasOwnProperty(key)) {
let cachedActions = cache[key]; const cachedActions = cache[key];
cachedActions.forEach((action) => { cachedActions.forEach((action) => {
action.input = null; action.input = null;
action.position = null; action.position = null;
...@@ -412,9 +412,9 @@ export class EditorInputActionContributor extends ActionBarContributor { ...@@ -412,9 +412,9 @@ export class EditorInputActionContributor extends ActionBarContributor {
this.clearInputsFromCache(context.position, true /* primary actions */); this.clearInputsFromCache(context.position, true /* primary actions */);
// First consult cache // First consult cache
let editorInput = context.input; const editorInput = context.input;
let editorPosition = context.position; const editorPosition = context.position;
let cachedActions = this.mapEditorInputActionContextToPrimaryActions[context.position][this.toId(context)]; const cachedActions = this.mapEditorInputActionContextToPrimaryActions[context.position][this.toId(context)];
if (cachedActions) { if (cachedActions) {
// Update the input field and position in all actions to indicate this change and return // Update the input field and position in all actions to indicate this change and return
...@@ -427,7 +427,7 @@ export class EditorInputActionContributor extends ActionBarContributor { ...@@ -427,7 +427,7 @@ export class EditorInputActionContributor extends ActionBarContributor {
} }
// Otherwise collect and keep in cache // Otherwise collect and keep in cache
let actions = this.getActionsForEditorInput(context); const actions = this.getActionsForEditorInput(context);
actions.forEach((action) => { actions.forEach((action) => {
action.input = editorInput; action.input = editorInput;
action.position = editorPosition; action.position = editorPosition;
...@@ -470,9 +470,9 @@ export class EditorInputActionContributor extends ActionBarContributor { ...@@ -470,9 +470,9 @@ export class EditorInputActionContributor extends ActionBarContributor {
this.clearInputsFromCache(context.position, false /* secondary actions */); this.clearInputsFromCache(context.position, false /* secondary actions */);
// First consult cache // First consult cache
let editorInput = context.input; const editorInput = context.input;
let editorPosition = context.position; const editorPosition = context.position;
let cachedActions = this.mapEditorInputActionContextToSecondaryActions[context.position][this.toId(context)]; const cachedActions = this.mapEditorInputActionContextToSecondaryActions[context.position][this.toId(context)];
if (cachedActions) { if (cachedActions) {
// Update the input field and position in all actions to indicate this change and return // Update the input field and position in all actions to indicate this change and return
...@@ -485,7 +485,7 @@ export class EditorInputActionContributor extends ActionBarContributor { ...@@ -485,7 +485,7 @@ export class EditorInputActionContributor extends ActionBarContributor {
} }
// Otherwise collect and keep in cache // Otherwise collect and keep in cache
let actions = this.getSecondaryActionsForEditorInput(context); const actions = this.getSecondaryActionsForEditorInput(context);
actions.forEach((action) => { actions.forEach((action) => {
action.input = editorInput; action.input = editorInput;
action.position = editorPosition; action.position = editorPosition;
......
...@@ -64,7 +64,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas ...@@ -64,7 +64,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
public createEditor(parent: Builder): void { public createEditor(parent: Builder): void {
// Left Container for Binary // Left Container for Binary
let leftBinaryContainerElement = document.createElement('div'); const leftBinaryContainerElement = document.createElement('div');
leftBinaryContainerElement.className = 'binary-container'; leftBinaryContainerElement.className = 'binary-container';
this.leftBinaryContainer = $(leftBinaryContainerElement); this.leftBinaryContainer = $(leftBinaryContainerElement);
this.leftBinaryContainer.tabindex(0); // enable focus support from the editor part (do not remove) this.leftBinaryContainer.tabindex(0); // enable focus support from the editor part (do not remove)
...@@ -82,7 +82,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas ...@@ -82,7 +82,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
this.sash.addListener2('reset', () => this.onSashReset()); this.sash.addListener2('reset', () => this.onSashReset());
// Right Container for Binary // Right Container for Binary
let rightBinaryContainerElement = document.createElement('div'); const rightBinaryContainerElement = document.createElement('div');
rightBinaryContainerElement.className = 'binary-container'; rightBinaryContainerElement.className = 'binary-container';
this.rightBinaryContainer = $(rightBinaryContainerElement); this.rightBinaryContainer = $(rightBinaryContainerElement);
this.rightBinaryContainer.tabindex(0); // enable focus support from the editor part (do not remove) this.rightBinaryContainer.tabindex(0); // enable focus support from the editor part (do not remove)
...@@ -94,11 +94,11 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas ...@@ -94,11 +94,11 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
} }
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> { public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
let oldInput = this.getInput(); const oldInput = this.getInput();
super.setInput(input, options); super.setInput(input, options);
// Detect options // Detect options
let forceOpen = options && options.forceOpen; const forceOpen = options && options.forceOpen;
// Same Input // Same Input
if (!forceOpen && input.matches(oldInput)) { if (!forceOpen && input.matches(oldInput)) {
...@@ -119,11 +119,11 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas ...@@ -119,11 +119,11 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
} }
// Render original // Render original
let original = <BinaryEditorModel>resolvedModel.originalModel; const original = <BinaryEditorModel>resolvedModel.originalModel;
this.renderInput(original.getName(), original.getResource(), original.getSize(), original.getETag(), true); this.renderInput(original.getName(), original.getResource(), original.getSize(), original.getETag(), true);
// Render modified // Render modified
let modified = <BinaryEditorModel>resolvedModel.modifiedModel; const modified = <BinaryEditorModel>resolvedModel.modifiedModel;
this.renderInput(modified.getName(), modified.getResource(), modified.getSize(), modified.getETag(), false); this.renderInput(modified.getName(), modified.getResource(), modified.getSize(), modified.getETag(), false);
}); });
} }
...@@ -138,8 +138,8 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas ...@@ -138,8 +138,8 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
} }
// Pass to ResourceViewer // Pass to ResourceViewer
let container = isOriginal ? this.leftBinaryContainer : this.rightBinaryContainer; const container = isOriginal ? this.leftBinaryContainer : this.rightBinaryContainer;
let scrollbar = isOriginal ? this.leftScrollbar : this.rightScrollbar; const scrollbar = isOriginal ? this.leftScrollbar : this.rightScrollbar;
ResourceViewer.show({ name, resource, size, etag }, container, scrollbar, (meta) => this.handleMetadataChanged(meta, isOriginal)); ResourceViewer.show({ name, resource, size, etag }, container, scrollbar, (meta) => this.handleMetadataChanged(meta, isOriginal));
} }
...@@ -172,14 +172,14 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas ...@@ -172,14 +172,14 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
} }
public layout(dimension: Dimension): void { public layout(dimension: Dimension): void {
let oldDimension = this.dimension; const oldDimension = this.dimension;
this.dimension = dimension; this.dimension = dimension;
// Calculate left hand container width based on sash move or fallback to 50% by default // Calculate left hand container width based on sash move or fallback to 50% by default
if (!this.leftContainerWidth || !oldDimension) { if (!this.leftContainerWidth || !oldDimension) {
this.leftContainerWidth = this.dimension.width / 2; this.leftContainerWidth = this.dimension.width / 2;
} else { } else {
let sashRatio = this.leftContainerWidth / oldDimension.width; const sashRatio = this.leftContainerWidth / oldDimension.width;
this.leftContainerWidth = this.dimension.width * sashRatio; this.leftContainerWidth = this.dimension.width * sashRatio;
} }
...@@ -208,7 +208,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas ...@@ -208,7 +208,7 @@ export class BinaryResourceDiffEditor extends BaseEditor implements IVerticalSas
private onSashDrag(e: ISashEvent): void { private onSashDrag(e: ISashEvent): void {
// Update Widths and keep in bounds of MIN_CONTAINER_WIDTH for both sides // Update Widths and keep in bounds of MIN_CONTAINER_WIDTH for both sides
let newLeftContainerWidth = this.startLeftContainerWidth + e.currentX - e.startX; const newLeftContainerWidth = this.startLeftContainerWidth + e.currentX - e.startX;
this.leftContainerWidth = Math.max(BinaryResourceDiffEditor.MIN_CONTAINER_WIDTH, newLeftContainerWidth); this.leftContainerWidth = Math.max(BinaryResourceDiffEditor.MIN_CONTAINER_WIDTH, newLeftContainerWidth);
if (this.dimension.width - this.leftContainerWidth < BinaryResourceDiffEditor.MIN_CONTAINER_WIDTH) { if (this.dimension.width - this.leftContainerWidth < BinaryResourceDiffEditor.MIN_CONTAINER_WIDTH) {
this.leftContainerWidth = this.dimension.width - BinaryResourceDiffEditor.MIN_CONTAINER_WIDTH; this.leftContainerWidth = this.dimension.width - BinaryResourceDiffEditor.MIN_CONTAINER_WIDTH;
......
...@@ -49,7 +49,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor { ...@@ -49,7 +49,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
public createEditor(parent: Builder): void { public createEditor(parent: Builder): void {
// Container for Binary // Container for Binary
let binaryContainerElement = document.createElement('div'); const binaryContainerElement = document.createElement('div');
binaryContainerElement.className = 'binary-container'; binaryContainerElement.className = 'binary-container';
this.binaryContainer = $(binaryContainerElement); this.binaryContainer = $(binaryContainerElement);
this.binaryContainer.tabindex(0); // enable focus support from the editor part (do not remove) this.binaryContainer.tabindex(0); // enable focus support from the editor part (do not remove)
...@@ -60,11 +60,11 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor { ...@@ -60,11 +60,11 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
} }
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> { public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
let oldInput = this.getInput(); const oldInput = this.getInput();
super.setInput(input, options); super.setInput(input, options);
// Detect options // Detect options
let forceOpen = options && options.forceOpen; const forceOpen = options && options.forceOpen;
// Same Input // Same Input
if (!forceOpen && input.matches(oldInput)) { if (!forceOpen && input.matches(oldInput)) {
...@@ -85,7 +85,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor { ...@@ -85,7 +85,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
} }
// Render Input // Render Input
let model = <BinaryEditorModel>resolvedModel; const model = <BinaryEditorModel>resolvedModel;
ResourceViewer.show({ name: model.getName(), resource: model.getResource(), size: model.getSize(), etag: model.getETag() }, this.binaryContainer, this.scrollbar, (meta) => this.handleMetadataChanged(meta)); ResourceViewer.show({ name: model.getName(), resource: model.getResource(), size: model.getSize(), etag: model.getETag() }, this.binaryContainer, this.scrollbar, (meta) => this.handleMetadataChanged(meta));
return TPromise.as<void>(null); return TPromise.as<void>(null);
......
...@@ -95,15 +95,15 @@ export class QuickOpenActionContributor extends ActionBarContributor { ...@@ -95,15 +95,15 @@ export class QuickOpenActionContributor extends ActionBarContributor {
} }
public hasActions(context: any): boolean { public hasActions(context: any): boolean {
let entry = this.getEntry(context); const entry = this.getEntry(context);
return !!entry; return !!entry;
} }
public getActions(context: any): IAction[] { public getActions(context: any): IAction[] {
let actions: Action[] = []; const actions: Action[] = [];
let entry = this.getEntry(context); const entry = this.getEntry(context);
if (entry) { if (entry) {
if (!this.openToSideActionInstance) { if (!this.openToSideActionInstance) {
this.openToSideActionInstance = this.instantiationService.createInstance(OpenToSideAction); this.openToSideActionInstance = this.instantiationService.createInstance(OpenToSideAction);
......
...@@ -120,8 +120,8 @@ export abstract class BaseEditorPicker extends QuickOpenHandler { ...@@ -120,8 +120,8 @@ export abstract class BaseEditorPicker extends QuickOpenHandler {
return true; return true;
} }
let resource = e.getResource(); const resource = e.getResource();
let targetToMatch = resource ? labels.getPathLabel(e.getResource(), this.contextService) : e.getLabel(); const targetToMatch = resource ? labels.getPathLabel(e.getResource(), this.contextService) : e.getLabel();
if (!scorer.matches(targetToMatch, normalizedSearchValueLowercase)) { if (!scorer.matches(targetToMatch, normalizedSearchValueLowercase)) {
return false; return false;
} }
......
...@@ -69,17 +69,17 @@ export class StringEditor extends BaseTextEditor { ...@@ -69,17 +69,17 @@ export class StringEditor extends BaseTextEditor {
} }
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> { public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
let oldInput = this.getInput(); const oldInput = this.getInput();
super.setInput(input, options); super.setInput(input, options);
// Detect options // Detect options
let forceOpen = options && options.forceOpen; const forceOpen = options && options.forceOpen;
// Same Input // Same Input
if (!forceOpen && input.matches(oldInput)) { if (!forceOpen && input.matches(oldInput)) {
// TextOptions (avoiding instanceof here for a reason, do not change!) // TextOptions (avoiding instanceof here for a reason, do not change!)
let textOptions = <TextEditorOptions>options; const textOptions = <TextEditorOptions>options;
if (textOptions && types.isFunction(textOptions.apply)) { if (textOptions && types.isFunction(textOptions.apply)) {
textOptions.apply(this.getControl()); textOptions.apply(this.getControl());
} }
...@@ -106,20 +106,20 @@ export class StringEditor extends BaseTextEditor { ...@@ -106,20 +106,20 @@ export class StringEditor extends BaseTextEditor {
} }
// Set Editor Model // Set Editor Model
let textEditor = this.getControl(); const textEditor = this.getControl();
let textEditorModel = (<BaseTextEditorModel>resolvedModel).textEditorModel; const textEditorModel = (<BaseTextEditorModel>resolvedModel).textEditorModel;
textEditor.setModel(textEditorModel); textEditor.setModel(textEditorModel);
// Apply Options from TextOptions // Apply Options from TextOptions
let optionsGotApplied = false; let optionsGotApplied = false;
let textOptions = <TextEditorOptions>options; const textOptions = <TextEditorOptions>options;
if (textOptions && types.isFunction(textOptions.apply)) { if (textOptions && types.isFunction(textOptions.apply)) {
optionsGotApplied = textOptions.apply(textEditor); optionsGotApplied = textOptions.apply(textEditor);
} }
// Otherwise restore View State // Otherwise restore View State
if (!optionsGotApplied && input instanceof UntitledEditorInput) { if (!optionsGotApplied && input instanceof UntitledEditorInput) {
let viewState = this.mapResourceToEditorViewState[input.getResource().toString()]; const viewState = this.mapResourceToEditorViewState[input.getResource().toString()];
if (viewState) { if (viewState) {
textEditor.restoreViewState(viewState); textEditor.restoreViewState(viewState);
} }
...@@ -131,16 +131,16 @@ export class StringEditor extends BaseTextEditor { ...@@ -131,16 +131,16 @@ export class StringEditor extends BaseTextEditor {
} }
protected getCodeEditorOptions(): IEditorOptions { protected getCodeEditorOptions(): IEditorOptions {
let options = super.getCodeEditorOptions(); const options = super.getCodeEditorOptions();
let input = this.getInput(); const input = this.getInput();
let isUntitled = input instanceof UntitledEditorInput; const isUntitled = input instanceof UntitledEditorInput;
let isReadonly = !isUntitled; // all string editors are readonly except for the untitled one const isReadonly = !isUntitled; // all string editors are readonly except for the untitled one
options.readOnly = isReadonly; options.readOnly = isReadonly;
let ariaLabel: string; let ariaLabel: string;
let inputName = input && input.getName(); const inputName = input && input.getName();
if (isReadonly) { if (isReadonly) {
ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0}. Readonly text editor.", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly text editor."); ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0}. Readonly text editor.", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly text editor.");
} else { } else {
...@@ -157,12 +157,12 @@ export class StringEditor extends BaseTextEditor { ...@@ -157,12 +157,12 @@ export class StringEditor extends BaseTextEditor {
* If smart reveal is true will only reveal the last line if the line before last is visible #3351 * If smart reveal is true will only reveal the last line if the line before last is visible #3351
*/ */
public revealLastLine(smartReveal = false): void { public revealLastLine(smartReveal = false): void {
let codeEditor = <ICodeEditor>this.getControl(); const codeEditor = <ICodeEditor>this.getControl();
let model = codeEditor.getModel(); const model = codeEditor.getModel();
const lineBeforeLastRevealed = codeEditor.getScrollTop() + codeEditor.getLayoutInfo().height >= codeEditor.getScrollHeight(); const lineBeforeLastRevealed = codeEditor.getScrollTop() + codeEditor.getLayoutInfo().height >= codeEditor.getScrollHeight();
if (model && (!smartReveal || lineBeforeLastRevealed)) { if (model && (!smartReveal || lineBeforeLastRevealed)) {
let lastLine = model.getLineCount(); const lastLine = model.getLineCount();
codeEditor.revealLine(lastLine); codeEditor.revealLine(lastLine);
} }
} }
......
...@@ -84,11 +84,11 @@ export class TextDiffEditor extends BaseTextEditor { ...@@ -84,11 +84,11 @@ export class TextDiffEditor extends BaseTextEditor {
this.previousDiffAction = new NavigateAction(this, false); this.previousDiffAction = new NavigateAction(this, false);
// Support navigation within the diff editor by overriding the editor service within // Support navigation within the diff editor by overriding the editor service within
let delegatingEditorService = this.instantiationService.createInstance(DelegatingWorkbenchEditorService, (input: EditorInput, options?: EditorOptions, arg3?: any) => { const delegatingEditorService = this.instantiationService.createInstance(DelegatingWorkbenchEditorService, (input: EditorInput, options?: EditorOptions, arg3?: any) => {
// Check if arg4 is a position argument that differs from this editors position // Check if arg4 is a position argument that differs from this editors position
if (types.isUndefinedOrNull(arg3) || arg3 === false || arg3 === this.position) { if (types.isUndefinedOrNull(arg3) || arg3 === false || arg3 === this.position) {
let activeDiffInput = <DiffEditorInput>this.getInput(); const activeDiffInput = <DiffEditorInput>this.getInput();
if (input && options && activeDiffInput) { if (input && options && activeDiffInput) {
// Input matches modified side of the diff editor: perform the action on modified side // Input matches modified side of the diff editor: perform the action on modified side
...@@ -98,7 +98,7 @@ export class TextDiffEditor extends BaseTextEditor { ...@@ -98,7 +98,7 @@ export class TextDiffEditor extends BaseTextEditor {
// Input matches original side of the diff editor: perform the action on original side // Input matches original side of the diff editor: perform the action on original side
else if (input.matches(activeDiffInput.originalInput)) { else if (input.matches(activeDiffInput.originalInput)) {
let originalEditor = this.getControl().getOriginalEditor(); const originalEditor = this.getControl().getOriginalEditor();
if (options instanceof TextEditorOptions) { if (options instanceof TextEditorOptions) {
(<TextEditorOptions>options).apply(originalEditor); (<TextEditorOptions>options).apply(originalEditor);
...@@ -112,23 +112,23 @@ export class TextDiffEditor extends BaseTextEditor { ...@@ -112,23 +112,23 @@ export class TextDiffEditor extends BaseTextEditor {
}); });
// Create a special child of instantiator that will delegate all calls to openEditor() to the same diff editor if the input matches with the modified one // Create a special child of instantiator that will delegate all calls to openEditor() to the same diff editor if the input matches with the modified one
let diffEditorInstantiator = this.instantiationService.createChild(new ServiceCollection([IWorkbenchEditorService, delegatingEditorService])); const diffEditorInstantiator = this.instantiationService.createChild(new ServiceCollection([IWorkbenchEditorService, delegatingEditorService]));
return diffEditorInstantiator.createInstance(DiffEditorWidget, parent.getHTMLElement(), this.getCodeEditorOptions()); return diffEditorInstantiator.createInstance(DiffEditorWidget, parent.getHTMLElement(), this.getCodeEditorOptions());
} }
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> { public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
let oldInput = this.getInput(); const oldInput = this.getInput();
super.setInput(input, options); super.setInput(input, options);
// Detect options // Detect options
let forceOpen = options && options.forceOpen; const forceOpen = options && options.forceOpen;
// Same Input // Same Input
if (!forceOpen && input.matches(oldInput)) { if (!forceOpen && input.matches(oldInput)) {
// TextOptions (avoiding instanceof here for a reason, do not change!) // TextOptions (avoiding instanceof here for a reason, do not change!)
let textOptions = <TextEditorOptions>options; const textOptions = <TextEditorOptions>options;
if (textOptions && types.isFunction(textOptions.apply)) { if (textOptions && types.isFunction(textOptions.apply)) {
textOptions.apply(<IDiffEditor>this.getControl()); textOptions.apply(<IDiffEditor>this.getControl());
} }
...@@ -155,13 +155,13 @@ export class TextDiffEditor extends BaseTextEditor { ...@@ -155,13 +155,13 @@ export class TextDiffEditor extends BaseTextEditor {
} }
// Editor // Editor
let diffEditor = <IDiffEditor>this.getControl(); const diffEditor = <IDiffEditor>this.getControl();
diffEditor.setModel((<TextDiffEditorModel>resolvedModel).textDiffEditorModel); diffEditor.setModel((<TextDiffEditorModel>resolvedModel).textDiffEditorModel);
// Respect text diff editor options // Respect text diff editor options
let autoRevealFirstChange = true; let autoRevealFirstChange = true;
if (options instanceof TextDiffEditorOptions) { if (options instanceof TextDiffEditorOptions) {
let textDiffOptions = (<TextDiffEditorOptions>options); const textDiffOptions = (<TextDiffEditorOptions>options);
autoRevealFirstChange = !types.isUndefinedOrNull(textDiffOptions.autoRevealFirstChange) ? textDiffOptions.autoRevealFirstChange : autoRevealFirstChange; autoRevealFirstChange = !types.isUndefinedOrNull(textDiffOptions.autoRevealFirstChange) ? textDiffOptions.autoRevealFirstChange : autoRevealFirstChange;
} }
...@@ -195,10 +195,10 @@ export class TextDiffEditor extends BaseTextEditor { ...@@ -195,10 +195,10 @@ export class TextDiffEditor extends BaseTextEditor {
private openAsBinary(input: EditorInput, options: EditorOptions): boolean { private openAsBinary(input: EditorInput, options: EditorOptions): boolean {
if (input instanceof DiffEditorInput) { if (input instanceof DiffEditorInput) {
let originalInput = input.originalInput; const originalInput = input.originalInput;
let modifiedInput = input.modifiedInput; const modifiedInput = input.modifiedInput;
let binaryDiffInput = new DiffEditorInput(input.getName(), input.getDescription(), originalInput, modifiedInput, true); const binaryDiffInput = new DiffEditorInput(input.getName(), input.getDescription(), originalInput, modifiedInput, true);
this.editorService.openEditor(binaryDiffInput, options, this.position).done(null, onUnexpectedError); this.editorService.openEditor(binaryDiffInput, options, this.position).done(null, onUnexpectedError);
...@@ -209,17 +209,17 @@ export class TextDiffEditor extends BaseTextEditor { ...@@ -209,17 +209,17 @@ export class TextDiffEditor extends BaseTextEditor {
} }
protected getCodeEditorOptions(): IEditorOptions { protected getCodeEditorOptions(): IEditorOptions {
let options: IDiffEditorOptions = super.getCodeEditorOptions(); const options: IDiffEditorOptions = super.getCodeEditorOptions();
let input = this.input; const input = this.input;
if (input instanceof DiffEditorInput) { if (input instanceof DiffEditorInput) {
let modifiedInput = input.modifiedInput; const modifiedInput = input.modifiedInput;
let readOnly = modifiedInput instanceof StringEditorInput || modifiedInput instanceof ResourceEditorInput; const readOnly = modifiedInput instanceof StringEditorInput || modifiedInput instanceof ResourceEditorInput;
options.readOnly = readOnly; options.readOnly = readOnly;
let ariaLabel: string; let ariaLabel: string;
let inputName = input && input.getName(); const inputName = input && input.getName();
if (readOnly) { if (readOnly) {
ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0}. Readonly text compare editor.", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly text compare editor."); ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0}. Readonly text compare editor.", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly text compare editor.");
} else { } else {
...@@ -236,7 +236,7 @@ export class TextDiffEditor extends BaseTextEditor { ...@@ -236,7 +236,7 @@ export class TextDiffEditor extends BaseTextEditor {
private isFileBinaryError(error: Error): boolean; private isFileBinaryError(error: Error): boolean;
private isFileBinaryError(error: any): boolean { private isFileBinaryError(error: any): boolean {
if (types.isArray(error)) { if (types.isArray(error)) {
let errors = <Error[]>error; const errors = <Error[]>error;
return errors.some((e) => this.isFileBinaryError(e)); return errors.some((e) => this.isFileBinaryError(e));
} }
...@@ -275,16 +275,16 @@ export class TextDiffEditor extends BaseTextEditor { ...@@ -275,16 +275,16 @@ export class TextDiffEditor extends BaseTextEditor {
} }
public getSecondaryActions(): IAction[] { public getSecondaryActions(): IAction[] {
let actions = super.getSecondaryActions(); const actions = super.getSecondaryActions();
const control = this.getControl(); const control = this.getControl();
let inlineModeActive = control && !control.renderSideBySide; let inlineModeActive = control && !control.renderSideBySide;
let inlineLabel = nls.localize('inlineDiffLabel', "Switch to Inline View"); const inlineLabel = nls.localize('inlineDiffLabel', "Switch to Inline View");
let sideBySideLabel = nls.localize('sideBySideDiffLabel', "Switch to Side by Side View"); const sideBySideLabel = nls.localize('sideBySideDiffLabel', "Switch to Side by Side View");
// Action to toggle editor mode from inline to side by side // Action to toggle editor mode from inline to side by side
let toggleEditorModeAction = new Action('toggle.diff.editorMode', inlineModeActive ? sideBySideLabel : inlineLabel, null, true, () => { const toggleEditorModeAction = new Action('toggle.diff.editorMode', inlineModeActive ? sideBySideLabel : inlineLabel, null, true, () => {
this.getControl().updateOptions(<IDiffEditorOptions>{ this.getControl().updateOptions(<IDiffEditorOptions>{
renderSideBySide: inlineModeActive renderSideBySide: inlineModeActive
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册