Skip to content

Commit 557517c

Browse files
USTHzhanglunickbeth
authored andcommitted
<feat>:limit final description len
1 parent 8892ec6 commit 557517c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/gui/usbipd_gui.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,15 @@ impl UsbipdGui {
172172
.unwrap_or_else(|| "Unknown Device".to_string()),
173173
);
174174
// if len > 32, truncate and add bus id
175-
if description.len() > 32 { // @todo use settings replace magic number
176-
description.truncate(32);
175+
if description.len() > 32 {
176+
// @todo use settings replace magic number
177177
let bus_id = device
178178
.bus_id
179179
.clone()
180180
.unwrap_or_else(|| "Unknown Bus".to_string());
181-
description.push_str(&format!("..(Bus:{})", bus_id));
181+
let bus_id_show = &format!("..(Bus:{})", bus_id); // not think it will be longer than 32
182+
description.truncate(32 - bus_id_show.len());
183+
description.push_str(bus_id_show);
182184
}
183185
if device.is_bound() {
184186
let menu_item = self

0 commit comments

Comments
 (0)