simplify fitNameColumn

as it wasn't using average and an average is too small anyway
This commit is contained in:
tophf 2022-09-15 12:58:05 +03:00
parent f5397b8aec
commit 0bb0d32c29

View File

@ -359,13 +359,10 @@ function fitNameColumn(styles) {
const lengths = styles.map(s => align + const lengths = styles.map(s => align +
(s = s.displayName || s.name || '').length + (s = s.displayName || s.name || '').length +
s.replace(/[^\u3000-\uFE00]+/g, '').length).sort(); // CJK glyphs are twice as wide s.replace(/[^\u3000-\uFE00]+/g, '').length).sort(); // CJK glyphs are twice as wide
const len = styles.length; const pick = .8; // for example, .8 = 80% in single line, 20% multiline
const fringe = len * 5 / 100 | 0; // ignoring 5% of outliers at each end const extras = 5; // an average for " UC ", "v1.0.0"
let avgName = 0; const res = lengths[styles.length * pick | 0] - align + extras;
for (let i = fringe; i < len - fringe; i++) { $.root.style.setProperty('--name-width', res + 'ch');
avgName = Math.max(avgName, lengths[i] - align);
}
$.root.style.setProperty('--name-width', avgName + 'ch');
} }
function fitSizeColumn(entries) { function fitSizeColumn(entries) {