mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 23:42:03 +00:00
Add guards
This commit is contained in:
parent
f5c868702b
commit
e76f47512c
3 changed files with 22 additions and 7 deletions
|
|
@ -15,8 +15,12 @@ export const SESSION_PAGE_SIZE = 20;
|
|||
* Truncates text to fit within a given width, adding ellipsis if needed.
|
||||
*/
|
||||
export function truncateText(text: string, maxWidth: number): string {
|
||||
if (text.length <= maxWidth) return text;
|
||||
if (maxWidth <= 3) return text.slice(0, maxWidth);
|
||||
if (text.length <= maxWidth) {
|
||||
return text;
|
||||
}
|
||||
if (maxWidth <= 3) {
|
||||
return text.slice(0, maxWidth);
|
||||
}
|
||||
return text.slice(0, maxWidth - 3) + '...';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue