提交 d3a27c31 编写于 作者: B Benjamin Pasero

fix #19504

上级 1ee3f9dc
......@@ -255,6 +255,7 @@ export class TabsTitleControl extends TitleControl {
const labels: IEditorInputLabel[] = [];
const mapLabelToDuplicates = new LinkedMap<string, IEditorInputLabel[]>();
const mapLabelAndDescriptionToDuplicates = new LinkedMap<string, IEditorInputLabel[]>();
// Build labels and descriptions for each editor
editors.forEach(editor => {
......@@ -268,17 +269,29 @@ export class TabsTitleControl extends TitleControl {
labels.push(item);
mapLabelToDuplicates.getOrSet(item.name, []).push(item);
if (typeof description === 'string') {
mapLabelAndDescriptionToDuplicates.getOrSet(`${item.name}${item.description}`, []).push(item);
}
});
// Mark duplicates and shorten their descriptions
const labelDuplicates = mapLabelToDuplicates.values();
labelDuplicates.forEach(duplicates => {
if (duplicates.length > 1) {
const shortenedDescriptions = shorten(duplicates.map(duplicate => duplicate.editor.getDescription()));
duplicates.forEach((duplicate, i) => {
duplicate.description = shortenedDescriptions[i];
duplicate.hasAmbiguousName = true;
duplicates = duplicates.filter(d => {
// we could have items with equal label and description. in that case it does not make much
// sense to produce a shortened version of the label, so we ignore those kind of items
return typeof d.description === 'string' && mapLabelAndDescriptionToDuplicates.get(`${d.name}${d.description}`).length === 1;
});
if (duplicates.length > 1) {
const shortenedDescriptions = shorten(duplicates.map(duplicate => duplicate.editor.getDescription()));
duplicates.forEach((duplicate, i) => {
duplicate.description = shortenedDescriptions[i];
duplicate.hasAmbiguousName = true;
});
}
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册