IJPL-161797 Remove code duplication in DefaultCutStrategy

The logic there matches exactly the one in UiUtil.
Except that the preferred size here is the same as
the full text size.

GitOrigin-RevId: be62bdb8b4696a62d06c27e439229ec333585af5
This commit is contained in:
Sergei Tachenov
2024-10-10 17:42:57 +03:00
committed by intellij-monorepo-bot
parent 207960de92
commit 2aa9576a72

View File

@@ -1,6 +1,7 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.wm.impl;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -28,8 +29,6 @@ public final class DefaultCutStrategy implements TextCutStrategy {
@Override
public int calcMinTextWidth(@NotNull String text, @NotNull FontMetrics metrics) {
if (text.length() < MIN_TEXT_LENGTH) return metrics.stringWidth(text);
text = text.substring(0, MIN_TEXT_LENGTH - 1);
return metrics.stringWidth(text + "...");
return UIUtil.computeTextComponentMinimumSize(metrics.stringWidth(text), text, metrics, MIN_TEXT_LENGTH - 1);
}
}