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

let => const; less use of FileEditorInput

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