本文整理匯總了TypeScript中vs/workbench/services/untitled/common/untitledEditorService.IUntitledEditorService.getDirty方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IUntitledEditorService.getDirty方法的具體用法?TypeScript IUntitledEditorService.getDirty怎麽用?TypeScript IUntitledEditorService.getDirty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/workbench/services/untitled/common/untitledEditorService.IUntitledEditorService
的用法示例。
在下文中一共展示了IUntitledEditorService.getDirty方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: saveAll
function saveAll(saveAllArguments: any, editorService: IWorkbenchEditorService, untitledEditorService: IUntitledEditorService,
textFileService: ITextFileService, editorGroupService: IEditorGroupService): TPromise<any> {
const stacks = editorGroupService.getStacksModel();
// Store some properties per untitled file to restore later after save is completed
const mapUntitledToProperties: { [resource: string]: { encoding: string; indexInGroups: number[]; activeInGroups: boolean[] } } = Object.create(null);
untitledEditorService.getDirty().forEach(resource => {
const activeInGroups: boolean[] = [];
const indexInGroups: number[] = [];
const encoding = untitledEditorService.getEncoding(resource);
// For each group
stacks.groups.forEach((group, groupIndex) => {
// Find out if editor is active in group
const activeEditor = group.activeEditor;
const activeResource = toResource(activeEditor, { supportSideBySide: true });
activeInGroups[groupIndex] = (activeResource && activeResource.toString() === resource.toString());
// Find index of editor in group
indexInGroups[groupIndex] = -1;
group.getEditors().forEach((editor, editorIndex) => {
const editorResource = toResource(editor, { supportSideBySide: true });
if (editorResource && editorResource.toString() === resource.toString()) {
indexInGroups[groupIndex] = editorIndex;
return;
}
});
});
mapUntitledToProperties[resource.toString()] = { encoding, indexInGroups, activeInGroups };
});
// Save all
return textFileService.saveAll(saveAllArguments).then(results => {
// Reopen saved untitled editors
const untitledToReopen: { input: IResourceInput, position: Position }[] = [];
results.results.forEach(result => {
if (!result.success || result.source.scheme !== Schemas.untitled) {
return;
}
const untitledProps = mapUntitledToProperties[result.source.toString()];
if (!untitledProps) {
return;
}
// For each position where the untitled file was opened
untitledProps.indexInGroups.forEach((indexInGroup, index) => {
if (indexInGroup >= 0) {
untitledToReopen.push({
input: {
resource: result.target,
encoding: untitledProps.encoding,
options: {
pinned: true,
index: indexInGroup,
preserveFocus: true,
inactive: !untitledProps.activeInGroups[index]
}
},
position: index
});
}
});
});
if (untitledToReopen.length) {
return editorService.openEditors(untitledToReopen).then(() => true);
}
return void 0;
});
}