fix tests

This commit is contained in:
Benjamin Pasero
2016-11-01 14:48:23 +01:00
parent 57c94f5b4f
commit 46ac4e6eb6
2 changed files with 16 additions and 32 deletions

View File

@@ -269,6 +269,11 @@ export function isEqual(path1: string, path2: string) {
} }
export function isParent(path: string, candidate: string): boolean { export function isParent(path: string, candidate: string): boolean {
if (!isLinux) {
path = path.toLowerCase();
candidate = candidate.toLowerCase();
}
return path.indexOf(candidate + paths.nativeSep) === 0; return path.indexOf(candidate + paths.nativeSep) === 0;
} }

View File

@@ -314,7 +314,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
} }
public reopenLastClosedEditor(): void { public reopenLastClosedEditor(): void {
this.ensureLoaded(); this.ensureHistoryLoaded();
const stacks = this.editorGroupService.getStacksModel(); const stacks = this.editorGroupService.getStacksModel();
@@ -343,7 +343,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
} }
public clear(): void { public clear(): void {
this.ensureLoaded(); this.ensureHistoryLoaded();
this.index = -1; this.index = -1;
this.stack.splice(0); this.stack.splice(0);
@@ -395,7 +395,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
return; return;
} }
this.ensureLoaded(); this.ensureHistoryLoaded();
const historyInput = this.preferResourceInput(input); const historyInput = this.preferResourceInput(input);
@@ -426,27 +426,10 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
this.removeFromRecentlyClosedFiles(arg1); this.removeFromRecentlyClosedFiles(arg1);
} }
private removeFromHistory(arg1: IEditorInput | IResourceInput | FileChangesEvent, index?: number): void { private removeFromHistory(arg1: IEditorInput | IResourceInput | FileChangesEvent): void {
this.ensureLoaded(); this.ensureHistoryLoaded();
if (typeof index !== 'number') { this.history = this.history.filter(e => !this.matches(arg1, e));
index = this.indexOf(arg1);
}
if (index >= 0) {
this.history.splice(index, 1);
}
}
private indexOf(arg1: IEditorInput | IResourceInput | FileChangesEvent): number {
for (let i = 0; i < this.history.length; i++) {
const entry = this.history[i];
if (this.matches(arg1, entry)) {
return i;
}
}
return -1;
} }
private handleEditorEventInStack(editor: IBaseEditor, storeSelection: boolean): void { private handleEditorEventInStack(editor: IBaseEditor, storeSelection: boolean): void {
@@ -593,11 +576,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
} }
private removeFromRecentlyClosedFiles(arg1: IEditorInput | IResourceInput | FileChangesEvent): void { private removeFromRecentlyClosedFiles(arg1: IEditorInput | IResourceInput | FileChangesEvent): void {
this.recentlyClosedFiles.forEach((e, i) => { this.recentlyClosedFiles = this.recentlyClosedFiles.filter(e => !this.matchesFile(e.resource, arg1));
if (this.matchesFile(e.resource, arg1)) {
this.recentlyClosedFiles.splice(i, 1);
}
});
} }
private isFileOpened(resource: URI, group: IEditorGroup): boolean { private isFileOpened(resource: URI, group: IEditorGroup): boolean {
@@ -658,14 +637,14 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
} }
public getHistory(): (IEditorInput | IResourceInput)[] { public getHistory(): (IEditorInput | IResourceInput)[] {
this.ensureLoaded(); this.ensureHistoryLoaded();
return this.history.slice(0); return this.history.slice(0);
} }
private ensureLoaded(): void { private ensureHistoryLoaded(): void {
if (!this.loaded) { if (!this.loaded) {
this.load(); this.loadHistory();
} }
this.loaded = true; this.loaded = true;
@@ -687,7 +666,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
this.storageService.store(HistoryService.STORAGE_KEY, JSON.stringify(entries), StorageScope.WORKSPACE); this.storageService.store(HistoryService.STORAGE_KEY, JSON.stringify(entries), StorageScope.WORKSPACE);
} }
private load(): void { private loadHistory(): void {
let entries: (ILegacySerializedEditorInput | ISerializedFileEditorInput)[] = []; let entries: (ILegacySerializedEditorInput | ISerializedFileEditorInput)[] = [];
const entriesRaw = this.storageService.get(HistoryService.STORAGE_KEY, StorageScope.WORKSPACE); const entriesRaw = this.storageService.get(HistoryService.STORAGE_KEY, StorageScope.WORKSPACE);