Skip to content

Commit 3c3bb07

Browse files
committed
revert changes
1 parent 8818e01 commit 3c3bb07

File tree

2 files changed

+10
-95
lines changed

2 files changed

+10
-95
lines changed

crates/ide/src/inlay_hints/adjustment.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ pub(super) fn hints(
205205
"`{}` → `{}`\n\n**{}**\n\n{}",
206206
source.display(sema.db, display_target),
207207
target.display(sema.db, display_target),
208-
coercion.chars().next().unwrap().to_uppercase().collect::<String>()
209-
+ &coercion[1..],
208+
coercion,
210209
detailed_tooltip
211210
))
212211
})),

crates/ide/src/inlay_hints/closing_brace.rs

Lines changed: 9 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ pub(super) fn hints(
9191
match_ast! {
9292
match parent {
9393
ast::Fn(it) => {
94-
let hint_text = format_function_hint(&it, config.max_length?)
95-
.unwrap_or_else(|| format!("fn {}", it.name().map(|n| n.to_string()).unwrap_or_default()));
96-
(hint_text, it.name().map(name))
94+
(format!("fn {}", it.name()?), it.name().map(name))
9795
},
9896
ast::Static(it) => (format!("static {}", it.name()?), it.name().map(name)),
9997
ast::Const(it) => {
@@ -156,47 +154,6 @@ pub(super) fn hints(
156154
None
157155
}
158156

159-
fn format_function_hint(func: &ast::Fn, max_length: usize) -> Option<String> {
160-
let name = func.name()?;
161-
let name_str = name.to_string();
162-
163-
let params = if let Some(param_list) = func.param_list() {
164-
let mut param_parts = Vec::new();
165-
let mut total_len = 0;
166-
let max_param_len = max_length.saturating_sub(name_str.len() + 4);
167-
168-
for param in param_list.params() {
169-
let param_text = if let Some(pat) = param.pat() {
170-
if let Some(ty) = param.ty() { format!("{}: {}", pat, ty) } else { pat.to_string() }
171-
} else if let Some(ty) = param.ty() {
172-
format!("_: {}", ty)
173-
} else {
174-
let param_source = param.syntax().text().to_string();
175-
if param_source.trim() == "..." { "...".to_owned() } else { "_".to_owned() }
176-
};
177-
178-
let param_len = param_text.len() + if param_parts.is_empty() { 0 } else { 2 };
179-
if total_len + param_len > max_param_len {
180-
param_parts.push("...".to_owned());
181-
break;
182-
}
183-
184-
total_len += param_len;
185-
param_parts.push(param_text);
186-
}
187-
188-
if param_parts.is_empty() {
189-
"()".to_owned()
190-
} else {
191-
format!("({})", param_parts.join(", "))
192-
}
193-
} else {
194-
"()".to_owned()
195-
};
196-
197-
Some(format!("fn {}{}", name_str, params))
198-
}
199-
200157
#[cfg(test)]
201158
mod tests {
202159
use crate::{
@@ -207,11 +164,7 @@ mod tests {
207164
#[test]
208165
fn hints_closing_brace() {
209166
check_with_config(
210-
InlayHintsConfig {
211-
closing_brace_hints_min_lines: Some(2),
212-
max_length: Some(30),
213-
..DISABLED_CONFIG
214-
},
167+
InlayHintsConfig { closing_brace_hints_min_lines: Some(2), ..DISABLED_CONFIG },
215168
r#"
216169
fn a() {}
217170
@@ -220,17 +173,17 @@ fn f() {
220173
221174
fn g() {
222175
}
223-
//^ fn g()
176+
//^ fn g
224177
225178
fn h<T>(with: T, arguments: u8, ...) {
226179
}
227-
//^ fn h(with: T, arguments: u8, ...)
180+
//^ fn h
228181
229182
trait Tr {
230183
fn f();
231184
fn g() {
232185
}
233-
//^ fn g()
186+
//^ fn g
234187
}
235188
//^ trait Tr
236189
impl Tr for () {
@@ -267,19 +220,15 @@ fn f() {
267220
let v = vec![
268221
];
269222
}
270-
//^ fn f()
223+
//^ fn f
271224
"#,
272225
);
273226
}
274227

275228
#[test]
276229
fn hints_closing_brace_for_block_expr() {
277230
check_with_config(
278-
InlayHintsConfig {
279-
closing_brace_hints_min_lines: Some(2),
280-
max_length: Some(10),
281-
..DISABLED_CONFIG
282-
},
231+
InlayHintsConfig { closing_brace_hints_min_lines: Some(2), ..DISABLED_CONFIG },
283232
r#"
284233
fn test() {
285234
'end: {
@@ -307,41 +256,8 @@ fn test() {
307256
//^ 'a
308257
309258
}
310-
//^ fn test()
311-
"#,
312-
);
313-
}
314-
315-
#[test]
316-
fn hints_closing_brace_function_parameters() {
317-
check_with_config(
318-
InlayHintsConfig {
319-
closing_brace_hints_min_lines: Some(1),
320-
max_length: Some(50),
321-
..DISABLED_CONFIG
322-
},
323-
r#"
324-
fn simple() {
325-
let v = vec![
326-
];
327-
}
328-
//^ fn simple()
329-
330-
fn with_params(x: i32, y: String) {
331-
332-
}
333-
//^ fn with_params(x: i32, y: String)
334-
335-
fn long_params(very_long_parameter_name: ComplexType, another: AnotherType) {
336-
337-
}
338-
//^ fn long_params(...)
339-
340-
fn many_params(a: i32, b: i32, c: i32, d: i32, e: i32) {
341-
342-
}
343-
//^ fn many_params(a: i32, b: i32, c: i32, d: i32, ...)
259+
//^ fn test
344260
"#,
345261
);
346262
}
347-
}
263+
}

0 commit comments

Comments
 (0)