gioser-graph: fix panic slicing multi-byte chars (á, ñ, etc)
- Use .chars().take(18) instead of byte slicing &node.name[..18] which panics on accented characters
This commit is contained in:
Binary file not shown.
@@ -248,8 +248,9 @@ impl GraphWidget {
|
|||||||
for (i, node) in self.nodes.iter().enumerate() {
|
for (i, node) in self.nodes.iter().enumerate() {
|
||||||
let Some((cx, cy)) = positions.get(i).map(|(_, p)| *p) else { continue; };
|
let Some((cx, cy)) = positions.get(i).map(|(_, p)| *p) else { continue; };
|
||||||
let color = camino_color(&node.camino).to_string();
|
let color = camino_color(&node.camino).to_string();
|
||||||
let label = if node.name.len() > 20 {
|
let label = if node.name.chars().count() > 20 {
|
||||||
format!("{}…", &node.name[..18])
|
let cutoff: String = node.name.chars().take(18).collect();
|
||||||
|
format!("{}…", cutoff)
|
||||||
} else {
|
} else {
|
||||||
node.name.clone()
|
node.name.clone()
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user