Skip to content

Commit 51e4d45

Browse files
committed
Do not print the internal struct name in LSP tooltip or error message
just strip the `slint::` or `slint::private_api::` This is not a 100% match to the slint name (eg, LogicalPosition) but it is better anyway
1 parent b44172b commit 51e4d45

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

internal/compiler/langtype.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ impl Display for Type {
157157
Type::Array(t) => write!(f, "[{}]", t),
158158
Type::Struct(t) => {
159159
if let Some(name) = &t.name {
160-
write!(f, "{}", name)
160+
if let Some(separator_pos) = name.rfind("::") {
161+
// write the slint type and not the native type
162+
write!(f, "{}", &name[separator_pos + 2..])
163+
} else {
164+
write!(f, "{}", name)
165+
}
161166
} else {
162167
write!(f, "{{ ")?;
163168
for (k, v) in &t.fields {

internal/compiler/tests/syntax/elements/text.slint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export component Foo inherits Rectangle {
55
Text {
66
font-metrics: 42;
77
// ^error{Cannot assign to output property 'font-metrics'}
8-
// ^^error{Cannot convert float to slint::private_api::FontMetrics}
8+
// ^^error{Cannot convert float to FontMetrics}
99

1010
}
1111

0 commit comments

Comments
 (0)