提交 4acd22df 编写于 作者: B Benjamin Pasero

let => const; less use of FileEditorInput

上级 3fc1538d
......@@ -64,8 +64,8 @@ export class SplitEditorAction extends Action {
options.pinned = true;
// Count editors
let visibleEditors = this.editorService.getVisibleEditors();
let editorCount = visibleEditors.length;
const visibleEditors = this.editorService.getVisibleEditors();
const editorCount = visibleEditors.length;
let targetPosition: Position;
switch (editorCount) {
......@@ -120,15 +120,15 @@ export class NavigateBetweenGroupsAction extends Action {
public run(): TPromise<any> {
// Can cycle split with active editor
let activeEditor = this.editorService.getActiveEditor();
const activeEditor = this.editorService.getActiveEditor();
if (!activeEditor) {
return TPromise.as(false);
}
// Cycle to the left and use module to start at 0 again
let visibleEditors = this.editorService.getVisibleEditors();
let editorCount = visibleEditors.length;
let newIndex = (activeEditor.position + 1) % editorCount;
const visibleEditors = this.editorService.getVisibleEditors();
const editorCount = visibleEditors.length;
const newIndex = (activeEditor.position + 1) % editorCount;
this.editorGroupService.focusGroup(<Position>newIndex);
......@@ -154,7 +154,7 @@ export class FocusFirstGroupAction extends Action {
public run(): TPromise<any> {
// Find left editor and focus it
let editors = this.editorService.getVisibleEditors();
const editors = this.editorService.getVisibleEditors();
for (let editor of editors) {
if (editor.position === Position.LEFT) {
this.editorGroupService.focusGroup(Position.LEFT);
......@@ -164,7 +164,7 @@ export class FocusFirstGroupAction extends Action {
}
// Since no editor is currently opened, try to open last history entry to the target side
let history = this.historyService.getHistory();
const history = this.historyService.getHistory();
for (let input of history) {
// For now only support to open resources from history to the side
......@@ -196,10 +196,10 @@ export abstract class BaseFocusSideGroupAction extends Action {
public run(): TPromise<any> {
// Require at least the reference editor to be visible
let editors = this.editorService.getVisibleEditors();
const editors = this.editorService.getVisibleEditors();
let referenceEditor: IEditor;
for (let i = 0; i < editors.length; i++) {
let editor = editors[i];
const editor = editors[i];
// Target editor exists so focus it
if (editor.position === this.getTargetEditorSide()) {
......@@ -232,7 +232,7 @@ export abstract class BaseFocusSideGroupAction extends Action {
// Otherwise try to find a history entry to open to the target editor side
else if (referenceEditor) {
let history = this.historyService.getHistory();
const history = this.historyService.getHistory();
for (let input of history) {
// For now only support to open files from history to the side
......@@ -311,7 +311,7 @@ export class FocusPreviousGroup extends Action {
public run(): TPromise<any> {
// Require an active editor
let activeEditor = this.editorService.getActiveEditor();
const activeEditor = this.editorService.getActiveEditor();
if (!activeEditor) {
return TPromise.as(true);
}
......@@ -355,7 +355,7 @@ export class FocusNextGroup extends Action {
// Find the next position to the right to use
let nextPosition: Position;
let activeEditor = this.editorService.getActiveEditor();
const activeEditor = this.editorService.getActiveEditor();
if (!activeEditor) {
nextPosition = Position.LEFT;
} else if (activeEditor.position === Position.LEFT) {
......@@ -387,7 +387,7 @@ export class OpenToSideAction extends Action {
}
private updateEnablement(): void {
let activeEditor = this.editorService.getActiveEditor();
const activeEditor = this.editorService.getActiveEditor();
this.enabled = (!activeEditor || activeEditor.position !== Position.RIGHT);
}
......@@ -395,7 +395,7 @@ export class OpenToSideAction extends Action {
let entry = toEditorQuickOpenEntry(context);
if (entry) {
let typedInputPromise: TPromise<EditorInput>;
let input = entry.getInput();
const input = entry.getInput();
if (input instanceof EditorInput) {
typedInputPromise = TPromise.as(input);
} else {
......@@ -413,7 +413,7 @@ export function toEditorQuickOpenEntry(element: any): IEditorQuickOpenEntry {
// QuickOpenEntryGroup
if (element instanceof QuickOpenEntryGroup) {
let group = <QuickOpenEntryGroup>element;
const group = <QuickOpenEntryGroup>element;
if (group.getEntry()) {
element = group.getEntry();
}
......@@ -442,11 +442,11 @@ export class CloseEditorAction extends Action {
}
public run(context?: IEditorContext): TPromise<any> {
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;
const position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;
// Close Active Editor
if (typeof position !== 'number') {
let activeEditor = this.editorService.getActiveEditor();
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
return this.editorService.closeEditor(activeEditor.position, activeEditor.input);
}
......@@ -456,7 +456,7 @@ export class CloseEditorAction extends Action {
if (!input) {
// Get Top Editor at Position
let visibleEditors = this.editorService.getVisibleEditors();
const visibleEditors = this.editorService.getVisibleEditors();
if (visibleEditors[position]) {
input = visibleEditors[position].input;
}
......@@ -485,7 +485,7 @@ export class CloseLeftEditorsInGroupAction extends Action {
}
public run(context?: IEditorContext): TPromise<any> {
let editor = getTarget(this.editorService, this.groupService, context);
const editor = getTarget(this.editorService, this.groupService, context);
if (editor) {
return this.editorService.closeEditors(editor.position, editor.input, Direction.LEFT);
}
......@@ -509,7 +509,7 @@ export class CloseRightEditorsInGroupAction extends Action {
}
public run(context?: IEditorContext): TPromise<any> {
let editor = getTarget(this.editorService, this.groupService, context);
const editor = getTarget(this.editorService, this.groupService, context);
if (editor) {
return this.editorService.closeEditors(editor.position, editor.input, Direction.RIGHT);
}
......@@ -549,7 +549,7 @@ export class CloseEditorsInOtherGroupsAction extends Action {
public run(context?: IEditorContext): TPromise<any> {
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;
if (typeof position !== 'number') {
let activeEditor = this.editorService.getActiveEditor();
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
position = activeEditor.position;
}
......@@ -613,7 +613,7 @@ export class CloseEditorsInGroupAction extends Action {
public run(context?: IEditorContext): TPromise<any> {
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;
if (typeof position !== 'number') {
let activeEditor = this.editorService.getActiveEditor();
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
position = activeEditor.position;
}
......@@ -644,14 +644,14 @@ export class MoveGroupLeftAction extends Action {
public run(context?: IEditorContext): TPromise<any> {
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;
if (typeof position !== 'number') {
let activeEditor = this.editorService.getActiveEditor();
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor && (activeEditor.position === Position.CENTER || activeEditor.position === Position.RIGHT)) {
position = activeEditor.position;
}
}
if (typeof position === 'number') {
let newPosition = (position === Position.CENTER) ? Position.LEFT : Position.CENTER;
const newPosition = (position === Position.CENTER) ? Position.LEFT : Position.CENTER;
// Move group
this.editorGroupService.moveGroup(position, newPosition);
......@@ -678,8 +678,8 @@ export class MoveGroupRightAction extends Action {
public run(context?: IEditorContext): TPromise<any> {
let position = context ? this.editorGroupService.getStacksModel().positionOfGroup(context.group) : null;
if (typeof position !== 'number') {
let activeEditor = this.editorService.getActiveEditor();
let editors = this.editorService.getVisibleEditors();
const activeEditor = this.editorService.getActiveEditor();
const editors = this.editorService.getVisibleEditors();
if ((editors.length === 2 && activeEditor.position === Position.LEFT) || (editors.length === 3 && activeEditor.position !== Position.RIGHT)) {
position = activeEditor.position;
......@@ -687,7 +687,7 @@ export class MoveGroupRightAction extends Action {
}
if (typeof position === 'number') {
let newPosition = (position === Position.LEFT) ? Position.CENTER : Position.RIGHT;
const newPosition = (position === Position.LEFT) ? Position.CENTER : Position.RIGHT;
// Move group
this.editorGroupService.moveGroup(position, newPosition);
......@@ -769,7 +769,7 @@ export class KeepEditorAction extends Action {
}
public run(context?: IEditorContext): TPromise<any> {
let target = getTarget(this.editorService, this.editorGroupService, context);
const target = getTarget(this.editorService, this.editorGroupService, context);
if (target) {
this.editorGroupService.pinEditor(target.position, target.input);
}
......@@ -1032,7 +1032,7 @@ export class BaseQuickOpenEditorInGroupAction extends Action {
}
public run(): TPromise<any> {
let keys = this.keybindingService.lookupKeybindings(this.id);
const keys = this.keybindingService.lookupKeybindings(this.id);
const stacks = this.editorGroupService.getStacksModel();
if (stacks.activeGroup) {
......@@ -1102,7 +1102,7 @@ export class OpenPreviousEditorFromHistoryAction extends Action {
}
public run(): TPromise<any> {
let keys = this.keybindingService.lookupKeybindings(this.id);
const keys = this.keybindingService.lookupKeybindings(this.id);
this.quickOpenService.show(null, { quickNavigateConfiguration: { keybindings: keys } });
......@@ -1152,7 +1152,7 @@ export class RemoveFromEditorHistoryAction extends Action {
public run(): TPromise<any> {
// Listen for next editor to open
let unbind = this.editorGroupService.onEditorOpening(e => {
const unbind = this.editorGroupService.onEditorOpening(e => {
unbind.dispose(); // listen once
e.prevent();
......
......@@ -127,7 +127,7 @@ export class BaseFileAction extends Action {
}
protected onErrorWithRetry(error: any, retry: () => TPromise<any>, extraAction?: Action): void {
let actions = [
const actions = [
new Action(this.id, nls.localize('retry', "Retry"), null, true, () => retry()),
CancelAction
];
......@@ -136,7 +136,7 @@ export class BaseFileAction extends Action {
actions.unshift(extraAction);
}
let errorWithRetry: IMessageWithAction = {
const errorWithRetry: IMessageWithAction = {
actions,
message: toErrorMessage(error, false)
};
......@@ -180,12 +180,12 @@ export class TriggerRenameFileAction extends BaseFileAction {
return TPromise.wrapError('No context provided to BaseEnableFileRenameAction.');
}
let viewletState = <IFileViewletState>context.viewletState;
const viewletState = <IFileViewletState>context.viewletState;
if (!viewletState) {
return TPromise.wrapError('Invalid viewlet state provided to BaseEnableFileRenameAction.');
return TPromise.wrapError('Invalid viewconst state provided to BaseEnableFileRenameAction.');
}
let stat = <IFileStat>context.stat;
const stat = <IFileStat>context.stat;
if (!stat) {
return TPromise.wrapError('Invalid stat provided to BaseEnableFileRenameAction.');
}
......@@ -193,7 +193,7 @@ export class TriggerRenameFileAction extends BaseFileAction {
viewletState.setEditable(stat, {
action: this.renameAction,
validator: (value) => {
let message = this.validateFileName(this.element.parent, value);
const message = this.validateFileName(this.element.parent, value);
if (!message) {
return null;
......@@ -210,7 +210,7 @@ export class TriggerRenameFileAction extends BaseFileAction {
this.tree.refresh(stat, false).then(() => {
this.tree.setHighlight(stat);
let unbind = this.tree.addListener2(CommonEventType.HIGHLIGHT, (e: IHighlightEvent) => {
const unbind = this.tree.addListener2(CommonEventType.HIGHLIGHT, (e: IHighlightEvent) => {
if (!e.highlight) {
viewletState.clearEditable(stat);
this.tree.refresh(stat).done(null, errors.onUnexpectedError);
......@@ -251,7 +251,7 @@ export abstract class BaseRenameAction extends BaseFileAction {
// Automatically trim whitespaces and trailing dots to produce nice file names
name = getWellFormedFileName(name);
let existingName = getWellFormedFileName(this.element.name);
const existingName = getWellFormedFileName(this.element.name);
// Return early if name is invalid or didn't change
if (name === existingName || this.validateFileName(this.element.parent, name)) {
......@@ -259,7 +259,7 @@ export abstract class BaseRenameAction extends BaseFileAction {
}
// Call function and Emit Event through viewer
let promise = this.runAction(name).then((stat: IFileStat) => {
const promise = this.runAction(name).then((stat: IFileStat) => {
if (stat) {
this.onSuccess(stat);
}
......@@ -392,14 +392,14 @@ export class BaseNewAction extends BaseFileAction {
return TPromise.wrapError('No context provided to BaseNewAction.');
}
let viewletState = <IFileViewletState>context.viewletState;
const viewletState = <IFileViewletState>context.viewletState;
if (!viewletState) {
return TPromise.wrapError('Invalid viewlet state provided to BaseNewAction.');
return TPromise.wrapError('Invalid viewconst state provided to BaseNewAction.');
}
let folder: FileStat = this.presetFolder;
if (!folder) {
let focus = <FileStat>this.tree.getFocus();
const focus = <FileStat>this.tree.getFocus();
if (focus) {
folder = focus.isDirectory ? focus : focus.parent;
} else {
......@@ -413,14 +413,14 @@ export class BaseNewAction extends BaseFileAction {
return this.tree.reveal(folder, 0.5).then(() => {
return this.tree.expand(folder).then(() => {
let stat = NewStatPlaceholder.addNewStatPlaceholder(folder, !this.isFile);
const stat = NewStatPlaceholder.addNewStatPlaceholder(folder, !this.isFile);
this.renameAction.element = stat;
viewletState.setEditable(stat, {
action: this.renameAction,
validator: (value) => {
let message = this.renameAction.validateFileName(folder, value);
const message = this.renameAction.validateFileName(folder, value);
if (!message) {
return null;
......@@ -439,7 +439,7 @@ export class BaseNewAction extends BaseFileAction {
return this.tree.reveal(stat, 0.5).then(() => {
this.tree.setHighlight(stat);
let unbind = this.tree.addListener2(CommonEventType.HIGHLIGHT, (e: IHighlightEvent) => {
const unbind = this.tree.addListener2(CommonEventType.HIGHLIGHT, (e: IHighlightEvent) => {
if (!e.highlight) {
stat.destroy();
this.tree.refresh(folder).done(null, errors.onUnexpectedError);
......@@ -514,8 +514,8 @@ export abstract class BaseGlobalNewAction extends Action {
return TPromise.timeout(100).then(() => { // use a timeout to prevent the explorer from revealing the active file
viewlet.focus();
let explorer = <ExplorerViewlet>viewlet;
let explorerView = explorer.getExplorerView();
const explorer = <ExplorerViewlet>viewlet;
const explorerView = explorer.getExplorerView();
// Not having a folder opened
if (!explorerView) {
......@@ -526,7 +526,7 @@ export abstract class BaseGlobalNewAction extends Action {
explorerView.expand();
}
let action = this.toDispose = this.instantiationService.createInstance(this.getAction(), explorerView.getViewer(), null);
const action = this.toDispose = this.instantiationService.createInstance(this.getAction(), explorerView.getViewer(), null);
return explorer.getActionRunner().run(action);
});
......@@ -562,7 +562,7 @@ export class GlobalNewUntitledFileAction extends Action {
}
public run(): TPromise<any> {
let input = this.untitledEditorService.createOrGet();
const input = this.untitledEditorService.createOrGet();
return this.editorService.openEditor(input, { pinned: true }); // untitled are always pinned
}
......@@ -755,7 +755,7 @@ export class BaseDeleteFileAction extends BaseFileAction {
this.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(this.element.clone(), null));
// Call function
let servicePromise = this.fileService.del(this.element.resource, this.useTrash).then(() => {
const servicePromise = this.fileService.del(this.element.resource, this.useTrash).then(() => {
if (this.element.parent) {
this.tree.setFocus(this.element.parent); // move focus to parent
}
......@@ -770,7 +770,7 @@ export class BaseDeleteFileAction extends BaseFileAction {
this.onErrorWithRetry(error, () => this.run(), extraAction);
// Since the delete failed, best we can do is to refresh the explorer from the root to show the current state of files.
let event = new LocalFileChangeEvent(new FileStat(this.contextService.getWorkspace().resource, true, true), new FileStat(this.contextService.getWorkspace().resource, true, true));
const event = new LocalFileChangeEvent(new FileStat(this.contextService.getWorkspace().resource, true, true), new FileStat(this.contextService.getWorkspace().resource, true, true));
this.eventService.emit('files.internal:fileChanged', event);
// Focus back to tree
......@@ -852,8 +852,8 @@ export class ImportFileAction extends BaseFileAction {
}
public run(context?: any): TPromise<any> {
let importPromise = TPromise.as(null).then(() => {
let input = context.input;
const importPromise = TPromise.as(null).then(() => {
const input = context.input;
if (input.files && input.files.length > 0) {
// Find parent for import
......@@ -869,9 +869,9 @@ export class ImportFileAction extends BaseFileAction {
}
// Create real files array
let filesArray: File[] = [];
const filesArray: File[] = [];
for (let i = 0; i < input.files.length; i++) {
let file = input.files[i];
const file = input.files[i];
filesArray.push(file);
}
......@@ -879,7 +879,7 @@ export class ImportFileAction extends BaseFileAction {
return this.fileService.resolveFile(targetElement.resource).then((targetStat: IFileStat) => {
// Check for name collisions
let targetNames: { [name: string]: IFileStat } = {};
const targetNames: { [name: string]: IFileStat } = {};
targetStat.children.forEach((child) => {
targetNames[isLinux ? child.name : child.name.toLowerCase()] = child;
});
......@@ -888,7 +888,7 @@ export class ImportFileAction extends BaseFileAction {
if (filesArray.some((file) => {
return !!targetNames[isLinux ? file.name : file.name.toLowerCase()];
})) {
let confirm: IConfirmation = {
const confirm: IConfirmation = {
message: nls.localize('confirmOverwrite', "A file or folder with the same name already exists in the destination folder. Do you want to replace it?"),
detail: nls.localize('irreversible', "This action is irreversible!"),
primaryButton: nls.localize({ key: 'replaceButtonLabel', comment: ['&& denotes a mnemonic'] }, "&&Replace")
......@@ -902,16 +902,16 @@ export class ImportFileAction extends BaseFileAction {
}
// Run import in sequence
let importPromisesFactory: ITask<TPromise<void>>[] = [];
const importPromisesFactory: ITask<TPromise<void>>[] = [];
filesArray.forEach((file) => {
importPromisesFactory.push(() => {
let sourceFile = URI.file((<any>file).path);
const sourceFile = URI.file((<any>file).path);
return this.fileService.importFile(sourceFile, targetElement.resource).then((result: IImportResult) => {
if (result.stat) {
// Emit Deleted Event if file gets replaced unless it is the same file
let oldFile = targetNames[isLinux ? file.name : file.name.toLowerCase()];
const oldFile = targetNames[isLinux ? file.name : file.name.toLowerCase()];
if (oldFile && oldFile.resource.fsPath !== result.stat.resource.fsPath) {
this.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(oldFile, null));
}
......@@ -1039,8 +1039,8 @@ export class PasteFileAction extends BaseFileAction {
}
// Check if file was deleted or moved meanwhile
let root: FileStat = this.tree.getInput();
let exists = root.find(fileToCopy.resource);
const root: FileStat = this.tree.getInput();
const exists = root.find(fileToCopy.resource);
if (!exists) {
fileToCopy = null;
return false;
......@@ -1065,7 +1065,7 @@ export class PasteFileAction extends BaseFileAction {
}
// Reuse duplicate action
let pasteAction = this.instantiationService.createInstance(DuplicateFileAction, this.tree, fileToCopy, target);
const pasteAction = this.instantiationService.createInstance(DuplicateFileAction, this.tree, fileToCopy, target);
return pasteAction.run().then(() => {
this.tree.DOMFocus();
......@@ -1105,7 +1105,7 @@ export class DuplicateFileAction extends BaseFileAction {
}
// Copy File and emit event
let result = this.fileService.copyFile(this.element.resource, this.findTarget()).then((stat: IFileStat) => {
const result = this.fileService.copyFile(this.element.resource, this.findTarget()).then((stat: IFileStat) => {
this.eventService.emit('files.internal:fileChanged', new LocalFileChangeEvent(null, stat));
}, (error: any) => {
this.onError(error);
......@@ -1119,7 +1119,7 @@ export class DuplicateFileAction extends BaseFileAction {
}
private findTarget(): URI {
let root: FileStat = this.tree.getInput();
const root: FileStat = this.tree.getInput();
let name = this.element.name;
let candidate = URI.file(paths.join(this.target.resource.fsPath, name));
......@@ -1143,7 +1143,7 @@ export class DuplicateFileAction extends BaseFileAction {
}
// file.txt=>file.1.txt
let lastIndexOfDot = name.lastIndexOf('.');
const lastIndexOfDot = name.lastIndexOf('.');
if (!isFolder && lastIndexOfDot >= 0) {
return strings.format('{0}.1{1}', name.substr(0, lastIndexOfDot), name.substr(lastIndexOfDot));
}
......@@ -1184,7 +1184,7 @@ export class OpenToSideAction extends Action {
}
private updateEnablement(): void {
let activeEditor = this.editorService.getActiveEditor();
const activeEditor = this.editorService.getActiveEditor();
this.enabled = (!activeEditor || activeEditor.position !== Position.RIGHT);
}
......@@ -1251,19 +1251,19 @@ export class GlobalCompareResourcesAction extends Action {
}
public run(): TPromise<any> {
let fileInput = asFileEditorInput(this.editorService.getActiveEditorInput());
const fileInput = asFileEditorInput(this.editorService.getActiveEditorInput());
if (fileInput) {
// Keep as resource to compare
globalResourceToCompare = fileInput.getResource();
// Listen for next editor to open
let unbind = this.editorGroupService.onEditorOpening(e => {
const unbind = this.editorGroupService.onEditorOpening(e => {
unbind.dispose(); // listen once
let otherFileInput = asFileEditorInput(e.editorInput);
const otherFileInput = asFileEditorInput(e.editorInput);
if (otherFileInput) {
let compareAction = this.instantiationService.createInstance(CompareResourcesAction, otherFileInput.getResource(), null);
const compareAction = this.instantiationService.createInstance(CompareResourcesAction, otherFileInput.getResource(), null);
if (compareAction._isEnabled()) {
e.prevent();
......@@ -1326,9 +1326,9 @@ export class CompareResourcesAction extends Action {
// Check if file was deleted or moved meanwhile (explorer only)
if (this.tree) {
let root: FileStat = this.tree.getInput();
const root: FileStat = this.tree.getInput();
if (root instanceof FileStat) {
let exists = root.find(globalResourceToCompare);
const exists = root.find(globalResourceToCompare);
if (!exists) {
globalResourceToCompare = null;
return false;
......@@ -1341,8 +1341,8 @@ export class CompareResourcesAction extends Action {
return false;
}
let mimeA = guessMimeTypes(this.resource.fsPath).join(', ');
let mimeB = guessMimeTypes(globalResourceToCompare.fsPath).join(', ');
const mimeA = guessMimeTypes(this.resource.fsPath).join(', ');
const mimeB = guessMimeTypes(globalResourceToCompare.fsPath).join(', ');
// Check if target has same mime
if (mimeA === mimeB) {
......@@ -1350,8 +1350,8 @@ export class CompareResourcesAction extends Action {
}
// Ensure the mode is equal if this is text (limitation of current diff infrastructure)
let isBinaryA = isBinaryMime(mimeA);
let isBinaryB = isBinaryMime(mimeB);
const isBinaryA = isBinaryMime(mimeA);
const isBinaryB = isBinaryMime(mimeB);
// Ensure we are not comparing binary with text
if (isBinaryA !== isBinaryB) {
......@@ -1368,8 +1368,8 @@ export class CompareResourcesAction extends Action {
this.tree.clearHighlight();
}
let leftInput = this.instantiationService.createInstance(FileEditorInput, globalResourceToCompare, void 0, void 0);
let rightInput = this.instantiationService.createInstance(FileEditorInput, this.resource, void 0, void 0);
const leftInput = this.instantiationService.createInstance(FileEditorInput, globalResourceToCompare, void 0, void 0);
const rightInput = this.instantiationService.createInstance(FileEditorInput, this.resource, void 0, void 0);
return this.editorService.openEditor(new DiffEditorInput(toDiffLabel(globalResourceToCompare, this.resource, this.contextService), null, leftInput, rightInput));
}
......@@ -1438,7 +1438,7 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
if (this.isSaveAs() || source.scheme === 'untitled') {
let mimeOfSource: string;
if (source.scheme === 'untitled') {
let selectedMime = this.untitledEditorService.get(source).getMime();
const selectedMime = this.untitledEditorService.get(source).getMime();
if (!isUnspecific(selectedMime)) {
mimeOfSource = [selectedMime, MIME_TEXT].join(', ');
}
......@@ -1448,7 +1448,7 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
if (source.scheme === 'untitled') {
encodingOfSource = this.untitledEditorService.get(source).getEncoding();
} else if (source.scheme === 'file') {
let textModel = this.textFileService.models.get(source);
const textModel = this.textFileService.models.get(source);
encodingOfSource = textModel && textModel.getEncoding(); // text model can be null e.g. if this is a binary file!
}
......@@ -1737,7 +1737,7 @@ export class RevertFileAction extends Action {
if (this.resource) {
resource = this.resource;
} else {
let activeFileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true);
const activeFileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true);
if (activeFileInput) {
resource = activeFileInput.getResource();
}
......@@ -1816,7 +1816,7 @@ export class ShowActiveFileInExplorer extends Action {
}
public run(): TPromise<any> {
let fileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true);
const fileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true);
if (fileInput) {
return this.viewletService.openViewlet(VIEWLET_ID, false).then((viewlet: ExplorerViewlet) => {
const isInsideWorkspace = this.contextService.isInsideWorkspace(fileInput.getResource());
......@@ -1948,7 +1948,7 @@ export function validateFileName(parent: IFileStat, name: string, allowOverwriti
// Max length restriction (on Windows)
if (isWindows) {
let fullPathLength = name.length + parent.resource.fsPath.length + 1 /* path segment */;
const fullPathLength = name.length + parent.resource.fsPath.length + 1 /* path segment */;
if (fullPathLength > 255) {
return nls.localize('filePathTooLongError', "The name **{0}** results in a path that is too long. Please choose a shorter name.", name);
}
......
......@@ -329,8 +329,7 @@ export class AcceptLocalChangesAction extends EditorInputAction {
}
// Reopen file input
const input = this.instantiationService.createInstance(FileEditorInput, model.getResource(), guessMimeTypes(model.getResource().fsPath).join(', '), void 0);
return this.editorService.openEditor(input, null, this.position).then(() => {
return this.editorService.openEditor({ resource: model.getResource() }, this.position).then(() => {
// Dispose conflict input
conflictInput.dispose();
......
......@@ -108,7 +108,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
public renderHeader(container: HTMLElement): void {
let titleDiv = $('div.title').appendTo(container);
const titleDiv = $('div.title').appendTo(container);
$('span').text(this.workspace.name).title(labels.getPathLabel(this.workspace.resource.fsPath)).appendTo(titleDiv);
super.renderHeader(container);
......@@ -136,7 +136,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Set Order
for (let i = 0; i < actions.length; i++) {
let action = actions[i];
const action = actions[i];
action.order = 10 * (i + 1);
}
......@@ -161,7 +161,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
private onEditorsChanged(): void {
let activeInput = this.editorService.getActiveEditorInput();
const activeInput = this.editorService.getActiveEditorInput();
let clearSelection = true;
let clearFocus = false;
......@@ -174,7 +174,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Select file if input is FileEditorInput
if (this.isVisible && this.contextService.isInsideWorkspace(fileResource)) {
let selection = this.hasSelection(fileResource);
const selection = this.hasSelection(fileResource);
if (!selection) {
this.select(fileResource).done(null, errors.onUnexpectedError);
}
......@@ -224,7 +224,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Make sure the current selected element is revealed
if (this.explorerViewer) {
if (this.autoReveal) {
let selection = this.explorerViewer.getSelection();
const selection = this.explorerViewer.getSelection();
if (selection.length > 0) {
this.reveal(selection[0], 0.5).done(null, errors.onUnexpectedError);
}
......@@ -236,7 +236,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
// Open the focused element in the editor if there is currently no file opened
let input = this.editorService.getActiveEditorInput();
const input = this.editorService.getActiveEditorInput();
if (!input || !(input instanceof FileEditorInput)) {
this.openFocusedElement(keepFocus);
}
......@@ -256,7 +256,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
// Always select the current navigated file in explorer if input is file editor input
let activeResource = this.getActiveEditorInputResource();
const activeResource = this.getActiveEditorInputResource();
if (activeResource) {
return refreshPromise.then(() => {
return this.select(activeResource);
......@@ -269,15 +269,14 @@ export class ExplorerView extends CollapsibleViewletView {
}
// Otherwise restore last used file: By lastActiveFileResource
let root = this.getInput();
const root = this.getInput();
let lastActiveFileResource: URI;
if (this.settings[ExplorerView.MEMENTO_LAST_ACTIVE_FILE_RESOURCE]) {
lastActiveFileResource = URI.parse(this.settings[ExplorerView.MEMENTO_LAST_ACTIVE_FILE_RESOURCE]);
}
if (lastActiveFileResource && root && root.find(lastActiveFileResource)) {
let editorInput = this.instantiationService.createInstance(FileEditorInput, lastActiveFileResource, void 0, void 0);
this.editorService.openEditor(editorInput, { revealIfVisible: true }).done(null, errors.onUnexpectedError);
this.editorService.openEditor({ resource: lastActiveFileResource, options: { revealIfVisible: true } }).done(null, errors.onUnexpectedError);
return refreshPromise;
}
......@@ -291,9 +290,9 @@ export class ExplorerView extends CollapsibleViewletView {
}
private openFocusedElement(preserveFocus?: boolean): void {
let stat: FileStat = this.explorerViewer.getFocus();
const stat: FileStat = this.explorerViewer.getFocus();
if (stat && !stat.isDirectory) {
let editorInput = this.instantiationService.createInstance(FileEditorInput, stat.resource, stat.mime, void 0);
const editorInput = this.instantiationService.createInstance(FileEditorInput, stat.resource, stat.mime, void 0);
this.editorService.openEditor(editorInput, { preserveFocus, revealIfVisible: true }).done(null, errors.onUnexpectedError);
}
......@@ -302,7 +301,7 @@ export class ExplorerView extends CollapsibleViewletView {
private getActiveEditorInputResource(): URI {
// Try with Editor Input
let input = this.editorService.getActiveEditorInput();
const input = this.editorService.getActiveEditorInput();
if (input && input instanceof FileEditorInput) {
return (<FileEditorInput>input).getResource();
}
......@@ -332,9 +331,9 @@ export class ExplorerView extends CollapsibleViewletView {
dnd,
accessibilityProvider
}, {
autoExpandSingleChildren: true,
ariaLabel: nls.localize('treeAriaLabel', "Files Explorer")
});
autoExpandSingleChildren: true,
ariaLabel: nls.localize('treeAriaLabel', "Files Explorer")
});
this.toDispose.push(lifecycle.toDisposable(() => renderer.dispose()));
......@@ -352,8 +351,8 @@ export class ExplorerView extends CollapsibleViewletView {
}
public getOptimalWidth(): number {
let parentNode = this.explorerViewer.getHTMLElement();
let childNodes = [].slice.call(parentNode.querySelectorAll('.explorer-item-label > a'));
const parentNode = this.explorerViewer.getHTMLElement();
const childNodes = [].slice.call(parentNode.querySelectorAll('.explorer-item-label > a'));
return DOM.getLargestChildWidth(parentNode, childNodes);
}
......@@ -366,18 +365,18 @@ export class ExplorerView extends CollapsibleViewletView {
// Add
if (e.gotAdded()) {
let addedElement = e.getAfter();
const addedElement = e.getAfter();
parentResource = URI.file(paths.dirname(addedElement.resource.fsPath));
parentElement = this.getInput().find(parentResource);
if (parentElement) {
// Add the new file to its parent (Model)
let childElement = FileStat.create(addedElement);
const childElement = FileStat.create(addedElement);
parentElement.removeChild(childElement); // make sure to remove any previous version of the file if any
parentElement.addChild(childElement);
let refreshPromise = () => {
const refreshPromise = () => {
// Refresh the Parent (View)
return this.explorerViewer.refresh(parentElement).then(() => {
......@@ -408,15 +407,15 @@ export class ExplorerView extends CollapsibleViewletView {
// Move (including Rename)
else if (e.gotMoved()) {
let oldElement = e.getBefore();
let newElement = e.getAfter();
const oldElement = e.getBefore();
const newElement = e.getAfter();
let oldParentResource = URI.file(paths.dirname(oldElement.resource.fsPath));
let newParentResource = URI.file(paths.dirname(newElement.resource.fsPath));
const oldParentResource = URI.file(paths.dirname(oldElement.resource.fsPath));
const newParentResource = URI.file(paths.dirname(newElement.resource.fsPath));
// Only update focus if renamed/moved element is selected
let updateFocus = false;
let focus: FileStat = this.explorerViewer.getFocus();
const focus: FileStat = this.explorerViewer.getFocus();
if (focus && focus.resource && focus.resource.toString() === oldElement.resource.toString()) {
updateFocus = true;
}
......@@ -448,8 +447,8 @@ export class ExplorerView extends CollapsibleViewletView {
// Handle Move
else if (oldParentResource && newParentResource) {
let oldParent = this.getInput().find(oldParentResource);
let newParent = this.getInput().find(newParentResource);
const oldParent = this.getInput().find(oldParentResource);
const newParent = this.getInput().find(newParentResource);
modelElement = this.getInput().find(oldElement.resource);
if (oldParent && newParent && modelElement) {
......@@ -472,7 +471,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Delete
else if (e.gotDeleted()) {
let deletedElement = e.getBefore();
const deletedElement = e.getBefore();
modelElement = this.getInput().find(deletedElement.resource);
if (modelElement && modelElement.parent) {
parent = modelElement.parent;
......@@ -491,7 +490,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Imported which replaced an existing file
else if (e instanceof FileImportedEvent) {
let importedElement: IFileStat = (<FileImportedEvent>e).getAfter();
const importedElement: IFileStat = (<FileImportedEvent>e).getAfter();
parentResource = URI.file(paths.dirname(importedElement.resource.fsPath));
parentElement = this.getInput().find(parentResource);
......@@ -513,7 +512,7 @@ export class ExplorerView extends CollapsibleViewletView {
// delete events can result in UI activity that will fill the memento again when multiple
// editors are closing)
setTimeout(() => {
let lastActiveResource: string = this.settings[ExplorerView.MEMENTO_LAST_ACTIVE_FILE_RESOURCE];
const lastActiveResource: string = this.settings[ExplorerView.MEMENTO_LAST_ACTIVE_FILE_RESOURCE];
if (lastActiveResource && e.contains(URI.parse(lastActiveResource), FileChangeType.DELETED)) {
this.settings[ExplorerView.MEMENTO_LAST_ACTIVE_FILE_RESOURCE] = null;
}
......@@ -542,24 +541,24 @@ export class ExplorerView extends CollapsibleViewletView {
// We only ever refresh from files/folders that got added or deleted
if (e.gotAdded() || e.gotDeleted()) {
let added = e.getAdded();
let deleted = e.getDeleted();
const added = e.getAdded();
const deleted = e.getDeleted();
let root = this.getInput();
const root = this.getInput();
if (!root) {
return false;
}
// Check added: Refresh if added file/folder is not part of resolved root and parent is part of it
let ignoredPaths: { [fsPath: string]: boolean } = <{ [fsPath: string]: boolean }>{};
const ignoredPaths: { [fsPath: string]: boolean } = <{ [fsPath: string]: boolean }>{};
for (let i = 0; i < added.length; i++) {
let change = added[i];
const change = added[i];
if (!this.contextService.isInsideWorkspace(change.resource)) {
continue; // out of workspace file
}
// Find parent
let parent = paths.dirname(change.resource.fsPath);
const parent = paths.dirname(change.resource.fsPath);
// Continue if parent was already determined as to be ignored
if (ignoredPaths[parent]) {
......@@ -567,7 +566,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
// Compute if parent is visible and added file not yet part of it
let parentStat = root.find(URI.file(parent));
const parentStat = root.find(URI.file(parent));
if (parentStat && parentStat.isDirectoryResolved && !root.find(change.resource)) {
return true;
}
......@@ -580,7 +579,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Check deleted: Refresh if deleted file/folder part of resolved root
for (let j = 0; j < deleted.length; j++) {
let del = deleted[j];
const del = deleted[j];
if (!this.contextService.isInsideWorkspace(del.resource)) {
continue; // out of workspace file
}
......@@ -600,12 +599,12 @@ export class ExplorerView extends CollapsibleViewletView {
return false; // we only want added / removed
}
let workspacePath = this.contextService.toWorkspaceRelativePath(change.resource);
const workspacePath = this.contextService.toWorkspaceRelativePath(change.resource);
if (!workspacePath) {
return false; // not inside workspace
}
let segments = workspacePath.split(/\//);
const segments = workspacePath.split(/\//);
return fn(change, segments);
}));
......@@ -641,7 +640,7 @@ export class ExplorerView extends CollapsibleViewletView {
if (this.autoReveal) {
resourceToFocus = this.getActiveEditorInputResource();
if (!resourceToFocus) {
let selection = this.explorerViewer.getSelection();
const selection = this.explorerViewer.getSelection();
if (selection && selection.length === 1) {
resourceToFocus = (<FileStat>selection[0]).resource;
}
......@@ -658,8 +657,8 @@ export class ExplorerView extends CollapsibleViewletView {
}
private doRefresh(): TPromise<void> {
let root = this.getInput();
let targetsToResolve: URI[] = [];
const root = this.getInput();
const targetsToResolve: URI[] = [];
let targetsToExpand: URI[] = [];
if (this.settings[ExplorerView.MEMENTO_EXPANDED_FOLDER_RESOURCES]) {
......@@ -668,7 +667,7 @@ export class ExplorerView extends CollapsibleViewletView {
// First time refresh: Receive target through active editor input or selection and also include settings from previous session
if (!root) {
let activeResource = this.getActiveEditorInputResource();
const activeResource = this.getActiveEditorInputResource();
if (activeResource) {
targetsToResolve.push(activeResource);
}
......@@ -684,12 +683,12 @@ export class ExplorerView extends CollapsibleViewletView {
}
// Load Root Stat with given target path configured
let options: IResolveFileOptions = { resolveTo: targetsToResolve };
let promise = this.fileService.resolveFile(this.workspace.resource, options).then(stat => {
const options: IResolveFileOptions = { resolveTo: targetsToResolve };
const promise = this.fileService.resolveFile(this.workspace.resource, options).then(stat => {
let explorerPromise: TPromise<void>;
// Convert to model
let modelStat = FileStat.create(stat, options.resolveTo);
const modelStat = FileStat.create(stat, options.resolveTo);
// First time refresh: The stat becomes the input of the viewer
if (!root) {
......@@ -728,7 +727,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Drop those path which are parents of the current one
for (let i = resolvedDirectories.length - 1; i >= 0; i--) {
let resource = resolvedDirectories[i];
const resource = resolvedDirectories[i];
if (stat.resource.toString().indexOf(resource.toString()) === 0) {
resolvedDirectories.splice(i);
}
......@@ -740,7 +739,7 @@ export class ExplorerView extends CollapsibleViewletView {
// Recurse into children
for (let i = 0; i < stat.children.length; i++) {
let child = stat.children[i];
const child = stat.children[i];
this.getResolvedDirectories(child, resolvedDirectories);
}
}
......@@ -758,28 +757,28 @@ export class ExplorerView extends CollapsibleViewletView {
}
// If path already selected, just reveal and return
let selection = this.hasSelection(resource);
const selection = this.hasSelection(resource);
if (selection) {
return reveal ? this.reveal(selection, 0.5) : TPromise.as(null);
}
// First try to get the stat object from the input to avoid a roundtrip
let root = this.getInput();
const root = this.getInput();
if (!root) {
return TPromise.as(null);
}
let fileStat = root.find(resource);
const fileStat = root.find(resource);
if (fileStat) {
return this.doSelect(fileStat, reveal);
}
// Stat needs to be resolved first and then revealed
let options: IResolveFileOptions = { resolveTo: [resource] };
const options: IResolveFileOptions = { resolveTo: [resource] };
return this.fileService.resolveFile(this.workspace.resource, options).then(stat => {
// Convert to model
let modelStat = FileStat.create(stat, options.resolveTo);
const modelStat = FileStat.create(stat, options.resolveTo);
// Update Input with disk Stat
FileStat.mergeLocalWithDisk(modelStat, root);
......@@ -791,7 +790,7 @@ export class ExplorerView extends CollapsibleViewletView {
}
private hasSelection(resource: URI): FileStat {
let currentSelection: FileStat[] = this.explorerViewer.getSelection();
const currentSelection: FileStat[] = this.explorerViewer.getSelection();
for (let i = 0; i < currentSelection.length; i++) {
if (currentSelection[i].resource.toString() === resource.toString()) {
......@@ -836,9 +835,9 @@ export class ExplorerView extends CollapsibleViewletView {
public shutdown(): void {
// Keep list of expanded folders to restore on next load
let root = this.getInput();
const root = this.getInput();
if (root) {
let expanded = this.explorerViewer.getExpandedElements()
const expanded = this.explorerViewer.getExpandedElements()
.filter((e: FileStat) => e.resource.toString() !== this.workspace.resource.toString())
.map((e: FileStat) => e.resource.toString());
......
......@@ -25,7 +25,6 @@ import {IDisposable} from 'vs/base/common/lifecycle';
import {ContributableActionProvider} from 'vs/workbench/browser/actionBarRegistry';
import {LocalFileChangeEvent, IFilesConfiguration, ITextFileService} from 'vs/workbench/parts/files/common/files';
import {IFileOperationResult, FileOperationResult, IFileStat, IFileService} from 'vs/platform/files/common/files';
import {FileEditorInput} from 'vs/workbench/parts/files/common/editors/fileEditorInput';
import {DuplicateFileAction, ImportFileAction, PasteFileAction, keybindingForAction, IEditableData, IFileViewletState} from 'vs/workbench/parts/files/browser/fileActions';
import {IDataSource, ITree, IElementCallback, IAccessibilityProvider, IRenderer, ContextMenuEvent, ISorter, IFilter, IDragAndDrop, IDragAndDropData, IDragOverReaction, DRAG_OVER_ACCEPT_BUBBLE_DOWN, DRAG_OVER_ACCEPT_BUBBLE_DOWN_COPY, DRAG_OVER_ACCEPT_BUBBLE_UP, DRAG_OVER_ACCEPT_BUBBLE_UP_COPY, DRAG_OVER_REJECT} from 'vs/base/parts/tree/browser/tree';
import {DesktopDragAndDropData, ExternalElementsDragAndDropData} from 'vs/base/parts/tree/browser/treeDnd';
......@@ -679,8 +678,7 @@ export class FileController extends DefaultController {
if (stat && !stat.isDirectory) {
this.telemetryService.publicLog('workbenchActionExecuted', { id: 'workbench.files.openFile', from: 'explorer' });
const editorInput = this.instantiationService.createInstance(FileEditorInput, stat.resource, stat.mime, void 0);
this.editorService.openEditor(editorInput, { preserveFocus, pinned }, sideBySide).done(null, errors.onUnexpectedError);
this.editorService.openEditor({ resource: stat.resource, mime: stat.mime, options: { preserveFocus, pinned } }, sideBySide).done(null, errors.onUnexpectedError);
}
}
......
......@@ -107,8 +107,7 @@ export class FileEditorTracker implements IWorkbenchContribution {
}
// Reopen
const editorInput = this.instantiationService.createInstance(FileEditorInput, reopenFileResource, mimeHint || MIME_UNKNOWN, void 0);
this.editorService.openEditor(editorInput, { preserveFocus: true, pinned: group.isPinned(input), index: group.indexOf(input), inactive: !group.isActive(input) }, stacks.positionOfGroup(group)).done(null, errors.onUnexpectedError);
this.editorService.openEditor({ resource: reopenFileResource, mime: mimeHint || MIME_UNKNOWN, options: { preserveFocus: true, pinned: group.isPinned(input), index: group.indexOf(input), inactive: !group.isActive(input) } }, stacks.positionOfGroup(group)).done(null, errors.onUnexpectedError);
}
}
});
......
......@@ -80,7 +80,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
if (includeDiff && editor.input instanceof DiffEditorInput) {
let diffInput = <DiffEditorInput>editor.input;
const diffInput = <DiffEditorInput>editor.input;
return input.matches(diffInput.modifiedInput) || input.matches(diffInput.originalInput);
}
......@@ -103,9 +103,9 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
// Support opening foreign resources (such as a http link that points outside of the workbench)
let resourceInput = <IResourceInput>input;
const resourceInput = <IResourceInput>input;
if (resourceInput.resource instanceof URI) {
let schema = resourceInput.resource.scheme;
const schema = resourceInput.resource.scheme;
if (schema === network.Schemas.http || schema === network.Schemas.https) {
window.open(resourceInput.resource.toString(true));
return TPromise.as<IEditor>(null);
......@@ -113,10 +113,10 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
// Untyped Text Editor Support (required for code that uses this service below workbench level)
let textInput = <IResourceInput>input;
return this.createInput(textInput).then((typedFileInput: EditorInput) => {
if (typedFileInput) {
return this.doOpenEditor(typedFileInput, TextEditorOptions.from(textInput), arg2);
const textInput = <IResourceInput>input;
return this.createInput(textInput).then(typedInput => {
if (typedInput) {
return this.doOpenEditor(typedInput, TextEditorOptions.from(textInput), arg2);
}
return TPromise.as<IEditor>(null);
......@@ -198,13 +198,9 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
public resolveEditorModel(input: IEditorInput, refresh?: boolean): TPromise<IEditorModel>;
public resolveEditorModel(input: IResourceInput, refresh?: boolean): TPromise<ITextEditorModel>;
public resolveEditorModel(input: any, refresh?: boolean): TPromise<IEditorModel> {
return this.createInput(input).then((workbenchInput: IEditorInput) => {
if (workbenchInput) {
// Resolve if applicable
if (workbenchInput instanceof EditorInput) {
return workbenchInput.resolve(!!refresh);
}
return this.createInput(input).then(typedInput => {
if (typedInput instanceof EditorInput) {
return typedInput.resolve(!!refresh);
}
return TPromise.as<IEditorModel>(null);
......@@ -221,21 +217,21 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
// Base Text Editor Support for inmemory resources
let resourceInput = <IResourceInput>input;
const resourceInput = <IResourceInput>input;
if (resourceInput.resource instanceof URI && resourceInput.resource.scheme === network.Schemas.inMemory) {
// For in-memory resources we only support to resolve the input from the current active editor
// because the workbench does not track editor models by in memory URL. This concept is only
// being used in the code editor.
let activeEditor = this.getActiveEditor();
const activeEditor = this.getActiveEditor();
if (activeEditor) {
let control = <ICommonEditor>activeEditor.getControl();
const control = <ICommonEditor>activeEditor.getControl();
if (types.isFunction(control.getEditorType)) {
// Single Editor: If code editor model matches, return input from editor
if (control.getEditorType() === EditorType.ICodeEditor) {
let codeEditor = <ICodeEditor>control;
let model = this.findModel(codeEditor, input);
const codeEditor = <ICodeEditor>control;
const model = this.findModel(codeEditor, input);
if (model) {
return TPromise.as(activeEditor.input);
}
......@@ -243,15 +239,15 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
// Diff Editor: If left or right code editor model matches, return associated input
else if (control.getEditorType() === EditorType.IDiffEditor) {
let diffInput = <DiffEditorInput>activeEditor.input;
let diffCodeEditor = <IDiffEditor>control;
const diffInput = <DiffEditorInput>activeEditor.input;
const diffCodeEditor = <IDiffEditor>control;
let originalModel = this.findModel(diffCodeEditor.getOriginalEditor(), input);
const originalModel = this.findModel(diffCodeEditor.getOriginalEditor(), input);
if (originalModel) {
return TPromise.as(diffInput.originalInput);
}
let modifiedModel = this.findModel(diffCodeEditor.getModifiedEditor(), input);
const modifiedModel = this.findModel(diffCodeEditor.getModifiedEditor(), input);
if (modifiedModel) {
return TPromise.as(diffInput.modifiedInput);
}
......@@ -292,7 +288,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
private findModel(editor: ICommonCodeEditor, input: IResourceInput): IModel {
let model = editor.getModel();
const model = editor.getModel();
if (!model) {
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册